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


Python factories.ApiKeyFactory类代码示例

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


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

示例1: test_allowed

 def test_allowed(self):
     api_key = ApiKeyFactory(allow_locate=True)
     self.assertTrue(api_key.allowed('locate'))
     self.assertTrue(api_key.allowed('region'))
     self.assertTrue(api_key.allowed('submit'))
     self.assertTrue(api_key.allowed('unknown') is None)
     self.assertFalse(ApiKeyFactory(allow_locate=None).allowed('locate'))
     self.assertFalse(ApiKeyFactory(allow_locate=False).allowed('locate'))
开发者ID:amolk4games,项目名称:ichnaea,代码行数:8,代码来源:test_api.py

示例2: test_allowed

 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,代码行数:10,代码来源:test_api.py

示例3: test_api_key_disallows

    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,代码行数:7,代码来源:test_fallback.py

示例4: setUpClass

 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,代码行数:9,代码来源:test_source.py

示例5: test_no_api_key_shortname

 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,代码行数:9,代码来源:test_query.py

示例6: _setup_table_contents

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,代码行数:10,代码来源:conftest.py

示例7: setUpClass

 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,代码行数:10,代码来源:test_source.py

示例8: setUp

 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,代码行数:10,代码来源:base.py

示例9: make_query

    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,代码行数:13,代码来源:base.py

示例10: _make_query

 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,代码行数:14,代码来源:test_query.py

示例11: _search

 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,代码行数:16,代码来源:test_searcher.py

示例12: setUpClass

 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,代码行数:19,代码来源:base.py

示例13: setUp

    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,代码行数:21,代码来源:test_fallback.py

示例14: test_api_key

 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,代码行数:5,代码来源:test_query.py

示例15: test_no_log

 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,代码行数:5,代码来源:test_query.py


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