Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_choose_host_raises_exception_when_no_hosts_available(self):
service = mock.Mock()
service.get_hosts.return_value = []
with pytest.raises(NoHostsAvailableException):
client.choose_host(service)
def test_choose_host_returns_one_of_the_available_hosts(self):
hosts = ["foo", "bar", "baz"]
service = mock.Mock()
service.get_hosts.return_value = hosts
assert client.choose_host(service) in hosts