Python google.appengine.ext.testbed.Testbed() Examples

The following are code examples for showing how to use google.appengine.ext.testbed.Testbed(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: bbq   Author: ocadotechnology   File: test_copy_job_service.py    Apache License 2.0 6 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        ndb.get_context().clear_cache()
        patch('googleapiclient.discovery.build').start()
        patch(
            'oauth2client.client.GoogleCredentials.get_application_default') \
            .start()
        self._create_http = patch.object(BigQuery, '_create_http').start()

        self.example_source_bq_table = BigQueryTable('source_project_id_1',
                                                     'source_dataset_id_1',
                                                     'source_table_id_1')
        self.example_target_bq_table = BigQueryTable('target_project_id_1',
                                                     'target_dataset_id_1',
                                                     'target_table_id_1') 
Example 2
Project: sndlatr   Author: Schibum   File: __init__.py    Apache License 2.0 6 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()

        self.testbed.activate()
        self.testbed.init_user_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_urlfetch_stub()
        self.testbed.init_mail_stub()
        self.testbed.init_taskqueue_stub(
            root_path=os.path.join(os.path.dirname(__file__), '..'))
        self.addCleanup(self.testbed.deactivate)

        self.taskqueue_stub = self.testbed.get_stub(
            testbed.TASKQUEUE_SERVICE_NAME)
        self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)

        urlfetch = self.testbed.get_stub('urlfetch')
        urlfetch._RetrieveURL = self.retrieve_mock
        self._response_queue = []
        self.patch_xsrf() 
Example 3
Project: Tinychat-Bot--Discontinued   Author: Tinychat   File: __init__.py    MIT License 6 votes vote down vote up
def setUp(self):
        if not has_appengine_sdk():
            self.skipTest('google appengine sdk not found')

        from google.appengine.ext import testbed

        util.ClassCacheClearingTestCase.setUp(self)

        self.testbed = testbed.Testbed()

        self.testbed.activate()

        # Next, declare which service stubs you want to use.
        for stub in self.testbed_stubs:
            func = getattr(self.testbed, 'init_%s_stub' % (stub,))

            func()

        self.addCleanup(self.testbed.deactivate) 
Example 4
Project: mlab-ns   Author: m-lab   File: test_sliver_tool_fetcher.py    Apache License 2.0 6 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_all_stubs()
        ndb.get_context().clear_cache()

        sliver_tool_fetcher_datastore_patch = mock.patch.object(
            sliver_tool_fetcher,
            'SliverToolFetcherDatastore',
            autospec=True)
        self.addCleanup(sliver_tool_fetcher_datastore_patch.stop)
        sliver_tool_fetcher_datastore_patch.start()

        sliver_tool_fetcher_memcache_patch = mock.patch.object(
            sliver_tool_fetcher,
            'SliverToolFetcherMemcache',
            autospec=True)
        self.addCleanup(sliver_tool_fetcher_memcache_patch.stop)
        sliver_tool_fetcher_memcache_patch.start()

        self.fetcher = sliver_tool_fetcher.SliverToolFetcher() 
Example 5
Project: graphene-gae   Author: graphql-python   File: base_test.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def setUp(self):
        super(BaseTest, self).setUp()

        root_path = '.'
        application_id = 'graphene-gae-test'

        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.setup_env(app_id=application_id, overwrite=True)
        policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=self.datastore_probability)
        self.testbed.init_datastore_v3_stub(root_path=root_path, consistency_policy=policy, require_indexes=True)
        self.testbed.init_app_identity_stub()
        self.testbed.init_blobstore_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(root_path=root_path)
        self.testbed.init_urlfetch_stub()
        self.storage = cloudstorage_stub.CloudStorageStub(self.testbed.get_stub('blobstore').storage)
        self.testbed.init_mail_stub()
        self.testbed.init_user_stub()
        self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)

        ndb.get_context().clear_cache()
        ndb.get_context().set_cache_policy(lambda x: True) 
Example 6
Project: ATTENDER   Author: denbedilov   File: attendees_tester.py    MIT License 6 votes vote down vote up
def setUp(self):
        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Next, declare which service stubs you want to use.
        self.testbed.init_datastore_v3_stub(User)
        self.testbed.init_memcache_stub()
        # Clear ndb's in-context cache between tests.
        # This prevents data from leaking between tests.
        # Alternatively, you could disable caching by
        # using ndb.get_context().set_cache_policy(False)
        ndb.get_context().clear_cache()
        self.mydb = DAL()
        self.obj = SearchEventsUsingAPI()
        event_id = self.mydb.set_event_details("222342395", "Hadoop Ecosystem Workshop", datetime.now(),
                                               "Tel Aviv-Yafo",  "Kiryat Atidim", "long-story-short", "rika pedro-shoham", "http://www.meetup.com", 64, "free", "All", "meetup")
        self.ev = event_id.id()

        self.mydb.set_user_details(10204308876621622, 'Itamar', 'Sharify', '[email protected]')
        self.mydb.set_user_details(10204308876621633, 'Olesya', 'Shapira', '[email protected]')
        self.mydb.set_user_details(10204308876621644, 'Rita', 'Markovich', '[email protected]') 
Example 7
Project: gae-webapp2-utils   Author: stanwood   File: appengine_fixtures.py    MIT License 6 votes vote down vote up
def testbed():
    """Helps with manipulate stubs for API testing on Google App Engine"""

    from google.appengine.datastore import datastore_stub_util
    from google.appengine.ext import testbed

    tb = testbed.Testbed()
    tb.consistency = datastore_stub_util.PseudoRandomHRConsistencyPolicy(
        probability=1,
    )
    tb.activate()
    tb.init_app_identity_stub()
    tb.init_datastore_v3_stub(consistency_policy=tb.consistency)
    tb.init_memcache_stub()
    tb.init_urlfetch_stub()
    tb.init_app_identity_stub()
    tb.init_search_stub()

    tb.init_taskqueue_stub(root_path='.')
    tb.MEMCACHE_SERVICE_NAME = testbed.MEMCACHE_SERVICE_NAME
    tb.TASKQUEUE_SERVICE_NAME = testbed.TASKQUEUE_SERVICE_NAME

    yield tb

    tb.deactivate() 
Example 8
Project: epschedule   Author: guberti   File: main_test.py    MIT License 5 votes vote down vote up
def setUp(self):
        # Test setup boilerplate.
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.test_app = webtest.TestApp(main.app) 
Example 9
Project: loaner   Author: google   File: loanertest.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
    """Set up the environment for testing."""
    super(TestCase, self).setUp()
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_user_stub()
    self.testbed.init_search_stub()
    self.testbed.init_taskqueue_stub()
    self.login_user()

    taskqueue_patcher = mock.patch.object(taskqueue, 'add')
    self.addCleanup(taskqueue_patcher.stop)
    self.taskqueue_add = taskqueue_patcher.start()
    self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)

    # The events.raise_event method raises an exception if there are no events
    # in datastore. It's called often in the model methods, many of which are
    # used in testing. When you want to test raise_event specifically, first run
    # stop() on this patcher; be sure to run start() again before end of test.
    def side_effect(event_name, device=None, shelf=None):
      """Side effect for raise_event that returns the model."""
      del event_name  # Unused.
      if device:
        return device
      else:
        return shelf

    self.testbed.mock_raiseevent = mock.Mock(side_effect=side_effect)
    self.testbed.raise_event_patcher = mock.patch.object(
        events, 'raise_event', self.testbed.mock_raiseevent)
    self.addCleanup(self.testbed.raise_event_patcher.stop)
    self.testbed.raise_event_patcher.start() 
Example 10
Project: platzi-hello-gae   Author: xertica-cloud   File: test.py    GNU General Public License v2.0 5 votes vote down vote up
def setUp(self):
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()
        # Setups app engine test bed. See: http://code.google.com/appengine/docs/python/tools/localunittesting.html#Introducing_the_Python_Testing_Utilities
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_user_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(root_path=".")
        self.task_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME) 
Example 11
Project: bbq   Author: ocadotechnology   File: test_cached_decorator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 12
Project: bbq   Author: ocadotechnology   File: test_task_creator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_taskqueue_stub(
            root_path=os.path.join(os.path.dirname(__file__), 'resources'))
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 13
Project: bbq   Author: ocadotechnology   File: test_result_check.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()
        patch('googleapiclient.discovery.build').start()
        patch(
            'oauth2client.client.GoogleCredentials.get_application_default') \
            .start() 
Example 14
Project: bbq   Author: ocadotechnology   File: test_result_check_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        app = result_check_handler.app
        self.under_test = webtest.TestApp(app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 15
Project: bbq   Author: ocadotechnology   File: test_copy_job_service_async.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        ndb.get_context().clear_cache()
        patch('googleapiclient.discovery.build').start()
        patch(
            'oauth2client.client.GoogleCredentials.get_application_default') \
            .start() 
Example 16
Project: bbq   Author: ocadotechnology   File: test_big_query_table_metadata.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 17
Project: bbq   Author: ocadotechnology   File: test_big_query_table_metadata.py    Apache License 2.0 5 votes vote down vote up
def test_create_same_empty_table_execute_a_proper_big_query_request_with_same_table_properties(self, create_table):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()

        table_properties = {
            "tableReference":{
                "projectId":"p1",
                "datasetId":"d1",
                "tableId":"t1",
            },
            "timePartitioning": {
                "type": "DAY",
                "field": "birth_date"
            },
            "schema": "a schema"
        }

        target_table_reference = TableReference("p2", "d2", "t2")
        BigQueryTableMetadata(table_properties).create_the_same_empty_table(target_table_reference)
        create_table.assert_called_with("p2","d2",
            {
            "tableReference":{
                "projectId":"p2",
                "datasetId":"d2",
                "tableId":"t2",
            },
            "timePartitioning": {
                "type": "DAY",
                "field": "birth_date"
            },
            "schema": "a schema"
        }) 
Example 18
Project: bbq   Author: ocadotechnology   File: test_big_query_table_metadata.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 19
Project: bbq   Author: ocadotechnology   File: test_big_query.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub()
        self._create_http = patch.object(BigQuery, '_create_http').start() 
Example 20
Project: bbq   Author: ocadotechnology   File: test_dataset_restore_service.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.taskqueue_stub = self.testbed.get_stub(
            testbed.TASKQUEUE_SERVICE_NAME)
        ndb.get_context().clear_cache()

        patch.object(Configuration, 'backup_project_id',
                     return_value=BACKUP_PROJECT_ID,
                     new_callable=PropertyMock).start()

        self.restore_service = patch(
            'src.restore.dataset'
            '.dataset_restore_service.AsyncBatchRestoreService').start()
        self.restore_service.return_value = self.restore_service

        self.location_validator = patch(
            'src.restore.dataset.dataset_restore_service.DatasetRestoreParametersValidator').start()
        self.location_validator.return_value = self.location_validator

        self.restore_items_generator = patch(
            'src.restore.dataset.dataset_restore_service.DatasetRestoreItemsGenerator').start()
        self.restore_items_generator.return_value = self.restore_items_generator

        self.freezer = freeze_time("2017-12-06")
        self.freezer.start() 
Example 21
Project: bbq   Author: ocadotechnology   File: test_dataset_restore_items_generator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        ndb.get_context().clear_cache()

        patch.object(Configuration, 'backup_project_id',
                     return_value=BACKUP_PROJECT_ID,
                     new_callable=PropertyMock).start()

        self.freezer = freeze_time("2017-12-06")
        self.freezer.start() 
Example 22
Project: bbq   Author: ocadotechnology   File: test_dataset_restore_parameters_validator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.BQ = patch(
            'src.restore.dataset.dataset_restore_parameters_validator.BigQuery').start()
        self.BQ.return_value = self.BQ 
Example 23
Project: bbq   Author: ocadotechnology   File: test_restoration_job_status_service.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 24
Project: bbq   Author: ocadotechnology   File: test_restore_workspace_creator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_app_identity_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()
        self.BQ = patch(
            'src.restore.async_batch_restore_service.BigQuery').start()
        patch.object(BigQueryTableMetadata, "get_table_by_reference_cached").start() 
Example 25
Project: bbq   Author: ocadotechnology   File: test_backup_list_restore_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.under_test = webtest.TestApp(backup_list_restore_handler.app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub() 
Example 26
Project: bbq   Author: ocadotechnology   File: test_restore_item.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 27
Project: bbq   Author: ocadotechnology   File: test_restoration_job.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 28
Project: bbq   Author: ocadotechnology   File: test_after_restore_action_handler.py    Apache License 2.0 5 votes vote down vote up
def init_webtest(self):
        self.under_test = webtest.TestApp(after_restore_action_handler.app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub() 
Example 29
Project: bbq   Author: ocadotechnology   File: test_async_restore_service.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        ndb.get_context().clear_cache()
        self.copy_service = \
            patch(
                'src.restore.async_batch_restore_service.CopyJobServiceAsync').start()
        patch('src.restore.async_batch_restore_service.BigQuery').start()
        patch.object(uuid, 'uuid4', return_value=HARDCODED_UUID).start()
        self.enforcer = patch.object(RestoreWorkspaceCreator,
                                     'create_workspace').start() 
Example 30
Project: bbq   Author: ocadotechnology   File: test_quality_sli_service.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        patch('oauth2client.client.GoogleCredentials.get_application_default') \
            .start()
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 31
Project: bbq   Author: ocadotechnology   File: test_latency_sli_service.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        patch('oauth2client.client.GoogleCredentials.get_application_default') \
            .start()
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 32
Project: bbq   Author: ocadotechnology   File: test_task_creator.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_taskqueue_stub(
            root_path=os.path.join(os.path.dirname(__file__), 'resources'))
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 33
Project: bbq   Author: ocadotechnology   File: test_default_backup_predicate.py    Apache License 2.0 5 votes vote down vote up
def initTestBedForDatastore(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 34
Project: bbq   Author: ocadotechnology   File: test_table_partitions_backup_scheduler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub()
        self.testbed.init_taskqueue_stub()
        ndb.get_context().clear_cache() 
Example 35
Project: bbq   Author: ocadotechnology   File: test_table.py    Apache License 2.0 5 votes vote down vote up
def init_testbed_for_datastore(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 36
Project: bbq   Author: ocadotechnology   File: test_after_backup_action_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.under_test = webtest.TestApp(after_backup_action_handler.app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_app_identity_stub()
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 37
Project: bbq   Author: ocadotechnology   File: test_on_demand_backup_predicate.py    Apache License 2.0 5 votes vote down vote up
def initTestBedForDatastore(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 38
Project: bbq   Author: ocadotechnology   File: test_on_demand_table_backup_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        app = on_demand_table_backup_handler.app
        self.under_test = webtest.TestApp(app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 39
Project: bbq   Author: ocadotechnology   File: test_backup_process.py    Apache License 2.0 5 votes vote down vote up
def init_test_bed_for_datastore(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub()
        self.testbed.init_taskqueue_stub()
        ndb.get_context().clear_cache() 
Example 40
Project: bbq   Author: ocadotechnology   File: test_backup_scheduler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_taskqueue_stub(
            root_path=os.path.join(os.path.dirname(__file__), 'resources'))
        self.task_queue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 41
Project: bbq   Author: ocadotechnology   File: test_table_backup.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub()
        self.testbed.init_taskqueue_stub()
        ndb.get_context().clear_cache() 
Example 42
Project: bbq   Author: ocadotechnology   File: test_organisation_retention.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        self.taskqueue_stub = utils.init_testbed_queue_stub(self.testbed) 
Example 43
Project: bbq   Author: ocadotechnology   File: test_table_retention_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        app = webapp2.WSGIApplication(
            [('/tasks/retention/table', TableRetentionHandler)])
        self.under_test = webtest.TestApp(app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub() 
Example 44
Project: bbq   Author: ocadotechnology   File: test_organisation_retention_handler.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        app = webapp2.WSGIApplication(
            [('/cron/retention', OrganizationRetentionHandler)])
        self.under_test = webtest.TestApp(app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub() 
Example 45
Project: bbq   Author: ocadotechnology   File: test_table_retention.py    Apache License 2.0 5 votes vote down vote up
def init_testbed_for_datastore(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache() 
Example 46
Project: github-stats   Author: lipis   File: quick_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    # Wrap the app with WebTest's TestApp.
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_memcache_stub()
    self.testbed.init_datastore_v3_stub()
    from main import app
    self.testapp = TestApp(app) 
Example 47
Project: zenn-la   Author: adesor   File: test_serializers.py    GNU General Public License v2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()

        self.sample_data = {
            'number': 1,
            'text': 'test_text'
        }
        self.test_serializer = TestSerializer() 
Example 48
Project: gae-init-magic   Author: gae-init   File: quick_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    # Wrap the app with WebTest's TestApp.
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_memcache_stub()
    self.testbed.init_datastore_v3_stub()
    from main import app
    self.testapp = TestApp(app) 
Example 49
Project: appengine-blobstoremigrator-python   Author: GoogleCloudPlatform   File: base.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
    super(BlobMigratorTestCase, self).setUp()
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_blobstore_stub()
    self.testbed.init_app_identity_stub()
    self.testbed.init_urlfetch_stub()
    self.testbed.init_files_stub()
    self.testbed.init_taskqueue_stub() 
Example 50
Project: pyaedj   Author: google   File: tests_middleware.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
    super(GoogleAuthenticationMiddlewareTests, self).setUp()

    self.old_environ = copy.deepcopy(os.environ)
    os.environ['AUTH_DOMAIN'] = 'google.com'
    os.environ['HTTP_SCHEME'] = 'http'

    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_mail_stub()
    self.testbed.init_user_stub() 
Example 51
Project: pyaedj   Author: google   File: testing.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
    super(BaseTestCase, self).setUp()
    dao.EphimeralStorageProvider._clear()  # pylint: disable=protected-access
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_user_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_taskqueue_stub(root_path='.')
    self.taskq = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME) 
Example 52
Project: flask-gae-ndb-starter   Author: jideobs   File: tests.py    MIT License 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
        self.testapp = webtest.TestApp(app) 
Example 53
Project: livremarketplace   Author: salomax   File: test_utils.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
    
        from google.appengine.ext import testbed
       
        tb = testbed.Testbed()
        tb.setup_env(current_version_id='testbed.version',
                     ENDPOINTS_AUTH_EMAIL='[email protected]',
                     ENDPOINTS_AUTH_DOMAIN='TEST_DOMAIN')
        tb.activate()
        tb.init_all_stubs()
        self.testbed = tb 
Example 54
Project: sndlatr   Author: Schibum   File: __init__.py    Apache License 2.0 5 votes vote down vote up
def setup_module():
    """Set up tests (used by e.g. nosetests) for the module - loaded once"""
    from google.appengine.ext import testbed
    global _appengine_testbed
    tb = testbed.Testbed()
    tb.activate()
    tb.setup_env()
    tb.init_datastore_v3_stub()
    tb.init_memcache_stub()

    _appengine_testbed = tb 
Example 55
Project: mlab-ns   Author: m-lab   File: test_maxmind.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_all_stubs() 
Example 56
Project: mlab-ns   Author: m-lab   File: test_sliver_tool_fetcher.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.fetcher = sliver_tool_fetcher.SliverToolFetcherMemcache()
        self.created_tools = [] 
Example 57
Project: mlab-ns   Author: m-lab   File: test_sliver_tool_fetcher.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.fetcher = sliver_tool_fetcher.SliverToolFetcherDatastore()
        self.db_root = db.Model(key_name='root')
        self.created_tools = [] 
Example 58
Project: mlab-ns   Author: m-lab   File: test_lookup.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub() 
Example 59
Project: mlab-ns   Author: m-lab   File: test_model.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub() 
Example 60
Project: mlab-ns   Author: m-lab   File: test_client_signature_fetcher.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.addCleanup(self.testbed.deactivate)
        self.testbed.init_all_stubs()
        ndb.get_context().clear_cache() 
Example 61
Project: mlab-ns   Author: m-lab   File: test_reverse_proxy.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_all_stubs()

        reverse_proxy._reverse_proxy = None 
Example 62
Project: gcp-census   Author: ocadotechnology   File: bigquery_client_test.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.under_test = webtest.TestApp(routes.app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub() 
Example 63
Project: gcp-census   Author: ocadotechnology   File: model_creator_handler_test.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        patch('googleapiclient.discovery.build').start()
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        app = webapp2.WSGIApplication(
            [('/createModels', ModelCreatorHandler)]
        )
        self.under_test = webtest.TestApp(app) 
Example 64
Project: gcp-census   Author: ocadotechnology   File: model_creator_test.py    Apache License 2.0 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_app_identity_stub() 
Example 65
Project: gcp-census   Author: ocadotechnology   File: bigquery_handler_test.py    Apache License 2.0 5 votes vote down vote up
def init_webtest(self):
        self.under_test = webtest.TestApp(routes.app)
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()

        path = os.path.join(os.path.dirname(__file__), '../config')
        logging.debug("queue.yaml path: %s", path)
        self.testbed.init_taskqueue_stub(root_path=path)
        self.taskqueue_stub = self.testbed.get_stub(
            testbed.TASKQUEUE_SERVICE_NAME)
        self.testbed.init_app_identity_stub() 
Example 66
Project: flasky-appengine   Author: russomi   File: test_client.py    MIT License 5 votes vote down vote up
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client(use_cookies=True)
        if self.app.config['MAIL_USE_GAE']:
            from google.appengine.ext import testbed

            self.testbed = testbed.Testbed()
            self.testbed.activate()
            self.testbed.init_mail_stub()
            self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME) 
Example 67
Project: ray   Author: felipevolpone   File: gae_test.py    MIT License 5 votes vote down vote up
def setUp(self):
        # fix enviroment
        app_id = 'myapp'
        os.environ['APPLICATION_ID'] = app_id
        apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
        stub = datastore_file_stub.DatastoreFileStub(app_id, '/dev/null', '/')
        apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)

        # activate mock services
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_user_stub()
        self.testbed.init_memcache_stub() 
Example 68
Project: ATTENDER   Author: denbedilov   File: eventbrite_tester.py    MIT License 5 votes vote down vote up
def setUp(self):
        self.api_object = ApiRequest()
        self.wrapper_object = SearchEventsUsingAPI()
        self.eventbrite_object = EventbriteApi()

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        ndb.get_context().clear_cache()

        self.testbed.init_urlfetch_stub() 
Example 69
Project: ATTENDER   Author: denbedilov   File: db_test.py    MIT License 5 votes vote down vote up
def setUp(self):
        # First, create an instance of the Testbed class.
        self.testbed = testbed.Testbed()
        # Then activate the testbed, which prepares the service stubs for use.
        self.testbed.activate()
        # Next, declare which service stubs you want to use.
        self.testbed.init_datastore_v3_stub(User)
        self.testbed.init_memcache_stub()
        # Clear ndb's in-context cache between tests.
        # This prevents data from leaking between tests.
        # Alternatively, you could disable caching by
        # using ndb.get_context().set_cache_policy(False)
        ndb.get_context().clear_cache()
        self.mydb = DAL()
        self.obj = SearchEventsUsingAPI() 
Example 70
Project: ATTENDER   Author: denbedilov   File: event_search_tester.py    MIT License 5 votes vote down vote up
def setUp(self):
        self.object =EventSearch()

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        ndb.get_context().clear_cache()

        self.testbed.init_urlfetch_stub() 
Example 71
Project: ATTENDER   Author: denbedilov   File: login_test.py    MIT License 5 votes vote down vote up
def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub(User)
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()
        self.mydb = DAL()
        self.obj = SearchEventsUsingAPI() 
Example 72
Project: tichu-tournament   Author: aragos   File: hand_preparation_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 73
Project: tichu-tournament   Author: aragos   File: hand_results_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 74
Project: tichu-tournament   Author: aragos   File: results_email_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_mail_stub()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)

    self.testapp = webtest.TestApp(main.app) 
Example 75
Project: tichu-tournament   Author: aragos   File: test_base.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 76
Project: tichu-tournament   Author: aragos   File: hand_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 77
Project: tichu-tournament   Author: aragos   File: movement_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.testapp = webtest.TestApp(main.app) 
Example 78
Project: tichu-tournament   Author: aragos   File: tournament_list_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 79
Project: tichu-tournament   Author: aragos   File: pair_id_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app) 
Example 80
Project: tichu-tournament   Author: aragos   File: auth_handler_test.py    MIT License 5 votes vote down vote up
def setUp(self):
    os.environ['AUTH_DOMAIN'] = 'testbed'

    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.testapp = webtest.TestApp(main.app)