def test_set_sdk_key_after_init(): ldclient.set_config(Config.default()) assert ldclient.get().is_initialized() is False ldclient.set_sdk_key(sdk_key) wait_until(ldclient.get().is_initialized, timeout=30) ldclient.get().close()
def test_set_sdk_key_before_init(): ldclient.set_config(Config.default()) ldclient.set_sdk_key(sdk_key) wait_until(ldclient.get().is_initialized, timeout=30) ldclient.get().close()
def test_sse_init(stream): stream.queue.put(Event(event="put", data=feature("foo", "jim"))) client = LDClient( "apikey", Config(feature_requester_class=partial(create_redis_ldd_requester, expiration=0), events=False)) wait_until(lambda: client.toggle("foo", user('xyz'), "blah") == "jim", timeout=10)
def test_set_config(): offline_config = ldclient.Config(offline=True) online_config = ldclient.Config(sdk_key=sdk_key, offline=False) ldclient.set_config(offline_config) assert ldclient.get().is_offline() is True ldclient.set_config(online_config) assert ldclient.get().is_offline() is False wait_until(ldclient.get().is_initialized, timeout=30) ldclient.get().close()
def test_set_sdk_key_before_init(): _reset_client() with start_server() as stream_server: with stream_content(make_put_event()) as stream_handler: try: stream_server.for_path('/all', stream_handler) ldclient.set_config(Config(sdk_key, stream_uri = stream_server.uri, send_events = False)) wait_until(ldclient.get().is_initialized, timeout=10) r = stream_server.await_request() assert r.headers['Authorization'] == sdk_key finally: _reset_client()
def test_set_sdk_key_after_init(): _reset_client() other_key = 'other-key' with start_server() as stream_server: with stream_content(make_put_event()) as stream_handler: try: stream_server.for_path('/all', BasicResponse(401)) config = Config(other_key, stream_uri = stream_server.uri, send_events = False) ldclient.set_config(config) assert ldclient.get().is_initialized() is False r = stream_server.await_request() assert r.headers['Authorization'] == other_key stream_server.for_path('/all', stream_handler) ldclient.set_config(config.copy_with_new_sdk_key(sdk_key)) wait_until(ldclient.get().is_initialized, timeout=30) r = stream_server.await_request() assert r.headers['Authorization'] == sdk_key finally: _reset_client()
def test_ctor_with_config(): client = LDClient(config=Config(sdk_key=sdk_key)) wait_until(client.is_initialized, timeout=10) client.close()
def test_ctor_with_config_polling(): client = LDClient(config=Config(sdk_key=sdk_key, stream=False)) wait_until(client.is_initialized, timeout=10) client.close()
def test_ctor_with_sdk_key_and_config(): client = LDClient(sdk_key=sdk_key, config=Config.default()) wait_until(client.is_initialized, timeout=10) client.close()
def test_ctor_with_sdk_key(): client = LDClient(sdk_key=sdk_key) wait_until(client.is_initialized, timeout=10) client.close()
def test_sse_init(stream): stream.queue.put(Event(event="put", data=feature("foo", "jim"))) client = LDClient("apikey", Config(feature_requester_class=partial(create_redis_ldd_requester, expiration=0), events=False)) wait_until(lambda: client.toggle( "foo", user('xyz'), "blah") == "jim", timeout=10)
def test_toggle(server): server.add_feature("foo", feature("foo", "jim")['foo']) client = LDClient("apikey", Config(base_uri=server.url)) wait_until(lambda: client.toggle("foo", user('xyz'), "blah") == "jim")
def test_sse_init(server, stream): stream.queue.put(Event(event="put", data=feature("foo", "jim"))) client = LDClient( "apikey", Config(stream=True, base_uri=server.url, stream_uri=stream.url)) wait_until(lambda: client.toggle("foo", user('xyz'), "blah") == "jim")
def test_sse_init(server, stream): stream.queue.put(Event(event="put", data=feature("foo", "jim"))) client = LDClient("apikey", Config(stream=True, base_uri=server.url, stream_uri=stream.url)) wait_until(lambda: client.toggle("foo", user('xyz'), "blah") == "jim")