def main(reactor): apiKey = 'whatever' client = TwistedLDClient(apiKey) user = { u'key': u'xyz', u'custom': { u'bizzle': u'def' } } val = yield client.toggle('foo', user) yield client.flush() print("Value: {}".format(val))
def test_sse_reconnect(server, stream): server.post_events() stream.queue.put(Event(event="put", data=feature("foo", "on"))) client = TwistedLDClient("apikey", TwistedConfig(stream=True, base_uri=server.url, stream_uri=stream.url)) yield wait_until(is_equal(lambda: client.toggle("foo", user('xyz'), "blah"), "on")) stream.stop() yield wait_until(is_equal(lambda: client.toggle("foo", user('xyz'), "blah"), "on")) stream.start() stream.queue.put(Event(event="put", data=feature("foo", "jim"))) client = TwistedLDClient("apikey", TwistedConfig(stream=True, base_uri=server.url, stream_uri=stream.url)) yield wait_until(is_equal(lambda: client.toggle("foo", user('xyz'), "blah"), "jim"))