def test_pickle_logged_in(self): api = RavelloClient() api.connect(env.service_url) api.login(env.username, env.password) pickled = pickle.dumps(api) api2 = pickle.loads(pickled) api2.hello() api2.close()
def test_retry_fail(self): api = RavelloClient(retries=3, timeout=5) api.connect(env.service_url) api.login(env.username, env.password) parsed = urlparse.urlsplit(env.service_url) ipaddr = socket.gethostbyname(parsed.netloc) with networkblocker.block_ip(ipaddr): assert_raises(RavelloError, api.hello) assert api._total_retries >= 3
def test_retry_succeed(self): api = RavelloClient(retries=4, timeout=5) api.connect(env.service_url) api.login(env.username, env.password) parsed = urlparse.urlsplit(env.service_url) ipaddr = socket.gethostbyname(parsed.netloc) def timed_block(secs): with networkblocker.block_ip(ipaddr): time.sleep(secs) thread = threading.Thread(target=timed_block, args=(12.5,)) thread.start() # Target IP is blocked for 12.5 seconds. 3 retries of 5 seconds # each are done. So on the last retry, this should work. api.hello() thread.join() assert api._total_retries >= 2
def test_login(self): api = RavelloClient() api.connect(env.service_url) api.login(env.username, env.password) api.close()