當前位置: 首頁>>代碼示例>>Python>>正文


Python ApiKeyFactory.build方法代碼示例

本文整理匯總了Python中ichnaea.tests.factories.ApiKeyFactory.build方法的典型用法代碼示例。如果您正苦於以下問題:Python ApiKeyFactory.build方法的具體用法?Python ApiKeyFactory.build怎麽用?Python ApiKeyFactory.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ichnaea.tests.factories.ApiKeyFactory的用法示例。


在下文中一共展示了ApiKeyFactory.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_allowed

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def test_allowed(self):
     api_key = ApiKeyFactory.build(allow_locate=True, allow_transfer=True)
     assert api_key.allowed('locate')
     assert api_key.allowed('region')
     assert api_key.allowed('submit')
     assert api_key.allowed('transfer')
     assert api_key.allowed('unknown') is None
     assert not ApiKeyFactory.build(allow_locate=None).allowed('locate')
     assert not ApiKeyFactory.build(allow_locate=False).allowed('locate')
     assert not ApiKeyFactory.build(allow_transfer=None).allowed('transfer')
開發者ID:jinsuki,項目名稱:ichnaea,代碼行數:12,代碼來源:test_api.py

示例2: test_api_key_disallows

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
    def test_api_key_disallows(self):
        api_key = ApiKeyFactory.build(allow_fallback=False)
        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(2)

        query = self.model_query(cells=cells, wifis=wifis, api_key=api_key)
        self.check_should_search(query, False)
開發者ID:voolitels,項目名稱:ichnaea,代碼行數:9,代碼來源:test_fallback.py

示例3: setUpClass

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def setUpClass(cls):
     super(SourceTest, cls).setUpClass()
     cls.api_key = ApiKeyFactory.build(valid_key='key')
     cls.source = cls.TestSource(
         geoip_db=cls.geoip_db,
         raven_client=cls.raven_client,
         redis_client=cls.redis_client,
         stats_client=cls.stats_client,
     )
開發者ID:amolk4games,項目名稱:ichnaea,代碼行數:11,代碼來源:test_source.py

示例4: test_no_api_key_shortname

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def test_no_api_key_shortname(self):
     api_key = ApiKeyFactory.build(shortname=None, log_locate=True)
     cell = CellFactory.build()
     self._make_query(api_key=api_key, cell=[cell])
     self.check_stats(counter=[
         ('locate.query',
             ['key:%s' % api_key.valid_key,
              'region:none', 'geoip:false', 'cell:one', 'wifi:none']),
     ])
開發者ID:voolitels,項目名稱:ichnaea,代碼行數:11,代碼來源:test_query.py

示例5: _setup_table_contents

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
def _setup_table_contents(conn):
    # Avoid import cycle
    from ichnaea.tests.factories import ApiKeyFactory

    conn.execute(text('DELETE FROM api_key'))
    conn.execute(text('DELETE FROM export_config'))
    key = ApiKeyFactory.build(valid_key='test')
    state = dict(key.__dict__)
    del state['_sa_instance_state']
    conn.execute(key.__table__.insert().values(state))
開發者ID:crankycoder,項目名稱:ichnaea,代碼行數:12,代碼來源:conftest.py

示例6: setUpClass

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def setUpClass(cls):
     super(SourceTest, cls).setUpClass()
     cls.api_key = ApiKeyFactory.build(shortname='key', log=True)
     cls.source = cls.TestSource(
         settings={'foo': '1'},
         geoip_db=cls.geoip_db,
         raven_client=cls.raven_client,
         redis_client=cls.redis_client,
         stats_client=cls.stats_client,
     )
開發者ID:therewillbecode,項目名稱:ichnaea,代碼行數:12,代碼來源:test_source.py

示例7: setUp

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def setUp(self):
     super(BaseSourceTest, self).setUp()
     self.api_key = ApiKeyFactory.build(shortname='test')
     self.source = self.TestSource(
         settings=self.settings,
         geoip_db=self.geoip_db,
         raven_client=self.raven_client,
         redis_client=self.redis_client,
         stats_client=self.stats_client,
     )
開發者ID:therewillbecode,項目名稱:ichnaea,代碼行數:12,代碼來源:base.py

示例8: make_query

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
    def make_query(self, geoip_db, http_session, session, stats, **kw):
        api_key = kw.pop(
            'api_key',
            ApiKeyFactory.build(valid_key='test', allow_fallback=True))

        return Query(
            api_key=api_key,
            api_type=self.api_type,
            session=session,
            http_session=http_session,
            geoip_db=geoip_db,
            stats_client=stats,
            **kw)
開發者ID:jinsuki,項目名稱:ichnaea,代碼行數:15,代碼來源:base.py

示例9: _make_query

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def _make_query(self, geoip_db, stats,
                 source, results, api_key=None, api_type='locate',
                 blue=(), cell=(), wifi=(), **kw):
     query = Query(
         api_key=api_key or ApiKeyFactory.build(valid_key='test'),
         api_type=api_type,
         blue=self.blue_model_query(blue),
         cell=self.cell_model_query(cell),
         wifi=self.wifi_model_query(wifi),
         geoip_db=geoip_db,
         stats_client=stats,
         **kw)
     query.emit_source_stats(source, results)
     return query
開發者ID:jinsuki,項目名稱:ichnaea,代碼行數:16,代碼來源:test_query.py

示例10: _search

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def _search(self, data_queues, geoip_db, raven, redis, stats, session,
             klass, **kw):
     query = Query(
         api_key=ApiKeyFactory.build(valid_key='test'),
         api_type='locate',
         session=session,
         stats_client=stats,
         **kw)
     searcher = klass(
         geoip_db=geoip_db,
         raven_client=raven,
         redis_client=redis,
         stats_client=stats,
         data_queues=data_queues,
     )
     return searcher.search(query)
開發者ID:amjadm61,項目名稱:ichnaea,代碼行數:18,代碼來源:test_searcher.py

示例11: setUpClass

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def setUpClass(cls):
     super(BaseSourceTest, cls).setUpClass()
     cls.api_key = ApiKeyFactory.build(valid_key='test')
     bhutan = cls.geoip_data['Bhutan']
     cls.bhutan_model = DummyModel(
         lat=bhutan['latitude'],
         lon=bhutan['longitude'],
         radius=bhutan['radius'],
         code=bhutan['region_code'],
         name=bhutan['region_name'],
         ip=bhutan['ip'])
     london = cls.geoip_data['London']
     cls.london_model = DummyModel(
         lat=london['latitude'],
         lon=london['longitude'],
         radius=london['radius'],
         code=london['region_code'],
         name=london['region_name'],
         ip=london['ip'])
開發者ID:mate1983,項目名稱:ichnaea,代碼行數:21,代碼來源:base.py

示例12: setUp

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
    def setUp(self):
        super(TestSource, self).setUp()

        self.api_key = ApiKeyFactory.build(allow_fallback=True)
        self.fallback_model = DummyModel(
            lat=51.5366, lon=0.03989, radius=1500.0)

        self.fallback_result = {
            'location': {
                'lat': self.fallback_model.lat,
                'lng': self.fallback_model.lon,
            },
            'accuracy': float(self.fallback_model.radius),
            'fallback': 'lacf',
        }
        self.fallback_cached_result = floatjson.float_dumps({
            'lat': self.fallback_model.lat,
            'lon': self.fallback_model.lon,
            'accuracy': float(self.fallback_model.radius),
            'fallback': 'lacf',
        })
開發者ID:mate1983,項目名稱:ichnaea,代碼行數:23,代碼來源:test_fallback.py

示例13: test_api_key

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def test_api_key(self):
     api_key = ApiKeyFactory.build()
     query = Query(api_key=api_key)
     self.assertEqual(query.api_key.valid_key, api_key.valid_key)
     self.assertEqual(query.api_key, api_key)
開發者ID:amolk4games,項目名稱:ichnaea,代碼行數:7,代碼來源:test_query.py

示例14: test_no_log

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def test_no_log(self):
     api_key = ApiKeyFactory.build(valid_key=None)
     self._make_query(self._make_result(),
                      api_key=api_key, api_type='locate')
     self.check_stats(total=0)
開發者ID:amolk4games,項目名稱:ichnaea,代碼行數:7,代碼來源:test_query.py

示例15: setUp

# 需要導入模塊: from ichnaea.tests.factories import ApiKeyFactory [as 別名]
# 或者: from ichnaea.tests.factories.ApiKeyFactory import build [as 別名]
 def setUp(self):
     super(SearcherTest, self).setUp()
     self.api_key = ApiKeyFactory.build(shortname='test')
     self.api_type = 'locate'
開發者ID:cemoulto,項目名稱:ichnaea,代碼行數:6,代碼來源:test_searcher.py


注:本文中的ichnaea.tests.factories.ApiKeyFactory.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。