当前位置: 首页>>代码示例>>Python>>正文


Python testbed.Testbed类代码示例

本文整理汇总了Python中google.appengine.ext.testbed.Testbed的典型用法代码示例。如果您正苦于以下问题:Python Testbed类的具体用法?Python Testbed怎么用?Python Testbed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Testbed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_save

 def test_save(self):
     testbed = Testbed()
     testbed.activate()
     testbed.init_datastore_v3_stub()
     testbed.init_memcache_stub()
     s = mommy.save_one(Stub)
     self.assertIsNotNone(s.key)
     testbed.deactivate()
开发者ID:renzon,项目名称:mommygae,代码行数:8,代码来源:mommy_tests.py

示例2: activate_test_stubs

    def activate_test_stubs(self, connection, datastore_path=None):
        if self.active_stubs == 'test':
            return

        if self.testbed is None:
            from google.appengine.ext.testbed import Testbed
            self.testbed = Testbed()

        self.testbed.activate()
        self.pre_test_stubs = self.active_stubs
        self.active_stubs = 'test'

        os.environ['APPLICATION_ID'] = 'dev~' + appid
        os.environ['HTTP_HOST'] = "%s.appspot.com" % appid

        appserver_opts = connection.settings_dict.get('DEV_APPSERVER_OPTIONS', {})
        high_replication = appserver_opts.get('high_replication', False)
        require_indexes = appserver_opts.get('require_indexes', False)
        use_sqlite = appserver_opts.get('use_sqlite', False)

        datastore_opts = {'require_indexes': require_indexes, 'use_sqlite': use_sqlite}

        if high_replication:
            from google.appengine.datastore import datastore_stub_util
            datastore_opts['consistency_policy'] = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)

        self.testbed.init_datastore_v3_stub(datastore_file=datastore_path, **datastore_opts)
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(auto_task_running=True, root_path=PROJECT_DIR)
        self.testbed.init_urlfetch_stub()
        self.testbed.init_user_stub()
        self.testbed.init_xmpp_stub()
        self.testbed.init_channel_stub()
开发者ID:Davidhw,项目名称:opportunitiesSite,代码行数:33,代码来源:stubs.py

示例3: setUp

    def setUp(self):
        unittest.TestCase.setUp(self)

        self._testbed = Testbed()
        self._testbed.activate()
        self._testbed.init_datastore_v3_stub()
        self._testbed.init_memcache_stub()
开发者ID:jeden,项目名称:uber-support,代码行数:7,代码来源:test_base_appengine_datastore_tester.py

示例4: setUp

 def setUp(self):
     TestCase.setUp(self)
     from google.appengine.ext.testbed import Testbed
     self.testbed = Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_memcache_stub()
开发者ID:TakashiSasaki,项目名称:odenkiapi-backup,代码行数:7,代码来源:RawDataNdb.py

示例5: activate_test_stubs

    def activate_test_stubs(self, connection):
        from google.appengine.ext.testbed import Testbed
        self.testbed = Testbed()

        if self.active_stubs == 'test':
            return

        os.environ['HTTP_HOST'] = "%s.appspot.com" % appid

        appserver_opts = connection.settings_dict.get('DEV_APPSERVER_OPTIONS', {})
        high_replication = appserver_opts.get('high_replication', False)

        datastore_opts = {}
        if high_replication:
            from google.appengine.datastore import datastore_stub_util
            datastore_opts['consistency_policy'] = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)

        self.testbed.activate()
        self.pre_test_stubs = self.active_stubs
        self.active_stubs = 'test'
        self.testbed.init_datastore_v3_stub(**datastore_opts)
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(auto_task_running=True, root_path=PROJECT_DIR)
        self.testbed.init_urlfetch_stub()
        self.testbed.init_user_stub()
        self.testbed.init_xmpp_stub()
        self.testbed.init_channel_stub()
开发者ID:twiglet,项目名称:twigletweb,代码行数:27,代码来源:stubs.py

示例6: setUp

    def setUp(self):
        from google.appengine.ext.testbed import Testbed

        self.testbed = Testbed()
        self.testbed.activate()
        # default setup with no param
        # you may re-setup in a test code by using this.
        self.setUpPyramid()
开发者ID:jbking,项目名称:netprintbox,代码行数:8,代码来源:utils.py

示例7: TestBase

class TestBase(TestCase):
    def setUp(self):
        from google.appengine.ext.testbed import Testbed

        self.testbed = Testbed()
        self.testbed.activate()
        # default setup with no param
        # you may re-setup in a test code by using this.
        self.setUpPyramid()

    def setUpPyramid(self, **kwargs):
        import netprintbox
        self.config = testing.setUp(**kwargs)
        self.config.include('netprintbox')

    def tearDown(self):
        self.testbed.deactivate()
        testing.tearDown()
开发者ID:jbking,项目名称:netprintbox,代码行数:18,代码来源:utils.py

示例8: setUp

 def setUp(self):
     """
     """
     self.testbed = Testbed()
     self.testbed.setup_env(app_id='dev~foobar')
     self.testbed.activate()
     self.testbed.init_memcache_stub()
     self.testbed.init_datastore_v3_stub(datastore_file='/tmp/appengine.foobar.kgreen/datastore.db',
                                         use_sqlite=True)
开发者ID:kellengreen,项目名称:katnap,代码行数:9,代码来源:tests.py

示例9: setUp

  def setUp(self):
    tb = Testbed()
    tb.activate()
    tb.init_datastore_v3_stub()
    tb.init_memcache_stub()
    tb.init_user_stub()
    self.testbed = tb

    self.orig_http = set_http_mock()
    self.orig_user = set_user_mock()
    
    self.current_user = users.get_current_user()
    self.secret = 'xsrfsecret123'
    self.cache = CredentialsStore()
    self.clear_cache()
开发者ID:ericgj,项目名称:fungi,代码行数:15,代码来源:test_gae_oauth.py

示例10: setUp

    def setUp(self):
        """Initialize stubs for testing.

        This initializes the following fields:
          self.testbed: An App Engine Testbed used for mocking App Engine
            services. This is activated, and any necessary stubs are
            initialized.
          self.testapp: A webtest.TestApp wrapping the CherryPy application.

        Subclasses that define their own setUp method should be sure to call
        this one as well.
        """

        self.__users = {}
        self.__admins = {}

        self.testbed = Testbed()
        self.testbed.activate()
        self.testbed.init_app_identity_stub()
        self.testbed.init_blobstore_stub()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_files_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub()
        self.testbed.init_user_stub()

        self.testapp = webtest.TestApp(Application())

        # Pretend we are running on AppEngine so that things like the error
        # page that behave differently when run locally act like they do in
        # production.
        os.environ['SERVER_SOFTWARE'] = 'Google App Engine/TESTING'

        # This private key is not actually used for anything other than testing.
        PrivateKey.set('''-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,CEB8C6541017AC8B

q1SgqAfgHXK5cQvtdIF8rkSlbAS6a92T5tYMVKJIW24giF5cw+1++X7X6S5ECykC
/iECExP7WfVlPDVoJMZpWGsYLMPhxncnKfUDICbVgwsO4KKeEv8lYTrvkY1sCZIx
kSja/lGAWpyxBnmxwoLh0LbLJBGUxUgn2Uqv/8Iid+w0m3NlgrllV+kOo4gUYF9q
bestH4nEQj6F0CeI8VPW0FxzMwn0vreHFBT5hul6xbNdB1vnRcz6ed4FiGXoAB5K
/8/Q2qyy1UPe2Hr9IoC6wo4h2kXq7pmhy/rtzU9/gjsGPD33ByavbgHAen0ajY5p
RmCx0AGidK9T6/SNoyDD9CMq7ypL+0JWoCeVoAEw2aZqN4rMJNbKMgPH+ajgiAXe
AWuMVjWN6uTL5+QJmWQct6a6TF8GPKdTcOZfNIXU5U9drHB2hggLcy6XkCYGjVJv
MvLascE4oAtOHnwz7WhrpcmX6F6Fww+TPnFzjk+IGJrnBUnAArEcM13IjiDUgg9B
iLuKimwrqasdBBY3Ua3SRMoG8PJoNKdsk1hDGlpxLnqOVUCvPKZuz4QnFusnUJrR
kiv+aqVBpZYymMh2Q1MWcogA7rL7LIowAkyLzS8dNwDhyk9jbO+1uoFSHKr5BTNv
cMJfCVm8pqhXwCVx3uYnhUzvth7mcEseXh5Dcg1RHka5rCXUz4eVxTkj1u3FOy9o
9jgARPpnDYsXH1lESxmiNZucHa50qI/ezNvQx8CbNa1/+JWoZ77yqM9qnDlXUwDY
1Sxqx9+4kthG9oyCzzUwFvhf1kTEHd0RfIapgjJ16HBQmzLnEPtjPA==
-----END RSA PRIVATE KEY-----''')

        self.dont_be_oauth_user()
开发者ID:kaisellgren,项目名称:pub-dartlang,代码行数:54,代码来源:testcase.py

示例11: setUp

    def setUp(self):
        from google.appengine.ext.testbed import Testbed

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

        self.username = os.environ.get('NETPRINT_USERNAME')
        self.password = os.environ.get('NETPRINT_PASSWORD')
        if self.username is None or self.password is None:
            raise SkipTest("Need both "
                           "NETPRINT_USERNAME and NETPRINT_PASSWORD")
开发者ID:jbking,项目名称:netprintbox,代码行数:12,代码来源:test_netprint.py

示例12: SimpleTest

class SimpleTest(unittest.TestCase):
    """
    """

    def setUp(self):
        """
        """
        self.testbed = Testbed()
        self.testbed.setup_env(app_id='dev~foobar')
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub(datastore_file='/tmp/appengine.foobar.kgreen/datastore.db',
                                            use_sqlite=True)

    def tearDown(self):
        self.testbed.deactivate()

    def test_index(self):
        model = DataModel(name='users',
                          value=[PropertyModel(name='first', value='John'),
                                 PropertyModel(name='last', value='Dough')])
        model.put()
开发者ID:kellengreen,项目名称:katnap,代码行数:22,代码来源:tests.py

示例13: _MyTest

class _MyTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        try:
            import webtest
        except ImportError:
            import setuptools.command.easy_install as easy_install

            easy_install.main(["WebTest"])
            exit()
        wsgi_application = webapp.WSGIApplication(paths)
        self.test_app = webtest.TestApp(wsgi_application)
        from google.appengine.ext.testbed import Testbed

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

    def tearDown(self):
        self.testbed.deactivate()
        unittest.TestCase.tearDown(self)


    def test_Path(self):
        response = self.test_app.get("/_Path")
        self.assertEqual(response.status, "200 OK")
        self.assertEqual(response.headers["Content-Type"], 'text/html; charset=utf-8')
        self.assertEqual(response.body, '/_Path')

    def test_Params(self):
        response = self.test_app.request(b"/_Params;ppp?a=b&c=d#e", method=b"GET")
        self.assertEqual(response.headers["a"], "abc")
        self.assertEqual(response.status, "200 OK")
        self.assertEqual(response.headers["Content-Type"], 'text/html; charset=utf-8')
        self.assertEqual(response.body, "")

    def test_Fragment(self):
        response = self.test_app.request(b"/_Fragment?a=b&c=d#e", method=b"GET")
        self.assertEqual(response.status, "200 OK")
        self.assertEqual(response.headers["Content-Type"], 'text/html; charset=utf-8')
        self.assertEqual(response.body, "e")

    def test_Query(self):
        response = self.test_app.request(b"/_Query?a=b&c=d#e", method=b"GET")
        self.assertEqual(response.status, "200 OK")
        self.assertEqual(response.headers["Content-Type"], 'text/html; charset=utf-8')
        self.assertEqual(response.body, "a=b&c=d")
开发者ID:TakashiSasaki,项目名称:odenkiapi,代码行数:48,代码来源:testRequestHandler.py

示例14: setUp

 def setUp(self):
     TestCase.setUp(self)
     try:
         import webtest
     except ImportError:
         import setuptools.command.easy_install as easy_install
         easy_install.main(["WebTest"])
         exit()
     self.test_app = webtest.TestApp(_wsgi_application)
     from google.appengine.ext.testbed import Testbed
     self.testbed = Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_memcache_stub()
开发者ID:TakashiSasaki,项目名称:odenkiapi-backup,代码行数:14,代码来源:post.py

示例15: testbed

def testbed():
    testbed = Testbed()
    testbed.activate()
    # testbed.setup_env(app_id='_')
    os.environ['APPLICATION_ID'] = '_'
    # This is a hack to get things working; `testbed.setup_env` does
    # not seem to be doing the job.
    # See: http://einaregilsson.com/unit-testing-model-classes-in-google-app-engine/

    # Will almost always need datastore for tests that use this fixture.
    testbed.init_datastore_v3_stub()
    # ndb uses memcache, so stub it as well.
    testbed.init_memcache_stub()
    # Clear in-context cache before test.
    ndb.get_context().clear_cache()

    yield testbed

    ndb.get_context().clear_cache()
    testbed.deactivate()
开发者ID:py-in-the-sky,项目名称:appengine-swapi,代码行数:20,代码来源:conftest.py


注:本文中的google.appengine.ext.testbed.Testbed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。