Module: AppEngine::Testing
- Defined in:
- lib/appengine-apis/testing.rb
Overview
Local testing support for Google App Engine
If you run your code on Google’s servers or under dev_appserver, the api’s are already configured.
To run outside this environment, you need to install a test environment and api stubs.
Class Method Summary collapse
- 
  
    
      .boot  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Loads stub API implementations if no API implementation is currently configured. 
- 
  
    
      .delegate  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    :nodoc:. 
- 
  
    
      .helper  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The LocalServiceTestHelper used by this class. 
- 
  
    
      .install_test_datastore  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Install stub apis and force all datastore operations to use an in-memory datastore. 
- .persistent_datastore ⇒ Object
- .persistent_datastore=(value) ⇒ Object
- .setup ⇒ Object
- .teardown ⇒ Object
Class Method Details
.boot ⇒ Object
Loads stub API implementations if no API implementation is currently configured.
Sets up a datastore saved to disk in ‘.’.
Does nothing is APIs are already configured (e.g. in production).
As a shortcut you can use
require 'appengine-apis/local_boot'
| 113 114 115 116 117 118 119 120 | # File 'lib/appengine-apis/testing.rb', line 113 def boot if delegate return end self.persistent_datastore = true setup at_exit {java.lang.System.exit(0)} end | 
.delegate ⇒ Object
:nodoc:
| 34 35 36 37 38 | # File 'lib/appengine-apis/testing.rb', line 34 def delegate # :nodoc: helper # make sure everything's loaded require 'appengine-apis/apiproxy' AppEngine::ApiProxy.getDelegate end | 
.helper ⇒ Object
The LocalServiceTestHelper used by this class. Use this to set the logged in user, etc.
| 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # File 'lib/appengine-apis/testing.rb', line 42 def helper failed = false @helper ||= begin testing = Java::ComGoogleAppengineToolsDevelopmentTesting @datastore_config = testing::LocalDatastoreServiceTestConfig.new configs = [ @datastore_config, testing::LocalBlobstoreServiceTestConfig.new, testing::LocalImagesServiceTestConfig.new, testing::LocalMailServiceTestConfig.new, testing::LocalMemcacheServiceTestConfig.new, # TODO: need a flag to optionally enable this # testing::LocalTaskQueueTestConfig.new, testing::LocalURLFetchServiceTestConfig.new, testing::LocalUserServiceTestConfig.new, testing::LocalXMPPServiceTestConfig.new, ].to_java(testing::LocalServiceTestConfig) testing::LocalServiceTestHelper.new(configs) rescue => ex if failed raise ex else failed = true require 'appengine-sdk' AppEngine::SDK.load_local_test_helper retry end end end | 
.install_test_datastore ⇒ Object
Install stub apis and force all datastore operations to use an in-memory datastore.
You may call this multiple times to reset to a new in-memory datastore.
| 76 77 78 79 | # File 'lib/appengine-apis/testing.rb', line 76 def install_test_datastore self.persistent_datastore = false setup end | 
.persistent_datastore ⇒ Object
| 81 82 83 84 | # File 'lib/appengine-apis/testing.rb', line 81 def persistent_datastore helper !@datastore_config.is_no_storage end | 
.persistent_datastore=(value) ⇒ Object
| 86 87 88 89 90 | # File 'lib/appengine-apis/testing.rb', line 86 def persistent_datastore=(value) helper @datastore_config.set_no_storage(!value) setup end | 
.setup ⇒ Object
| 92 93 94 95 96 97 | # File 'lib/appengine-apis/testing.rb', line 92 def setup if delegate teardown rescue nil end helper.setUp end | 
.teardown ⇒ Object
| 99 100 101 | # File 'lib/appengine-apis/testing.rb', line 99 def teardown helper.tearDown end |