def test_publish_signature(self): client = Client(self.url + "/publish-signed", key="key", secret="secret", timeout=5) publish_id = client.publish("test.publish", 4, 7, event="new event") self.assertNotEqual(publish_id, None)
def test_call_signature(self): client = Client(self.url + "/call-signature", key="key", secret="secret", timeout=5) result = client.call("test.add", 2, 3, offset=10) self.assertEqual(result, 15)
def test_call_no_callee(self): client = Client(self.url + "/call", timeout=5) self.assertRaises(ClientNoCalleeRegistered, client.call, "test.does_not_exist", 2, 3, offset=10)
def test_publish_missing_signature_params(self): client = Client(self.url + "/publish-signed", timeout=5) self.assertRaises(ClientMissingParams, client.publish, "test.publish", 4, 7, event="new event")
def test_publish_bad_url(self): client = Client(self.url + "/publish_bad_url", timeout=5) self.assertRaises(ClientBadUrl, client.publish, "test.publish", 4, 7, event="new event")
def test_call_bad_host(self): client = Client("http://bad:8001/call", timeout=5) self.assertRaises(ClientBadHost, client.call, "test.add", 2, 3, offset=10)
def test_publish_bad_host(self): client = Client("http://bad:8001/publish", timeout=5) self.assertRaises(ClientBadHost, client.publish, "test.publish", 4, 7, event="new event")
def test_call_missing_signature_params(self): client = Client(self.url + "/call-signature", timeout=5) self.assertRaises(ClientMissingParams, client.call, "test.add", 2, 3, offset=10)
def test_call_bad_url(self): client = Client(self.url + "/call_bad_url", timeout=5) self.assertRaises(ClientBadUrl, client.call, "test.add", 2, 3, offset=10)
def test_invalid_call_params(self): client = Client(self.url + "/call-signature", key="key", secret="secret", timeout=5) client._make_api_call = mock.MagicMock(return_value="{}") result = client.call("test.add", 2, 3, offset=10) self.assertEqual(result, None)
def test_publish_bad_signature(self): client = Client(self.url + "/publish-signed", key="key", secret="bad secret", timeout=5) self.assertRaises(ClientSignatureError, client.publish, "test.publish", 4, 7, event="new event")
def test_call_bad_signature(self): client = Client(self.url + "/call-signature", key="key", secret="bad secret", timeout=5) self.assertRaises(ClientSignatureError, client.call, "test.add", 2, 3, offset=10)
def test_publish_request_failed_http_exception(self, api_call_mock): """ Client must pass silently if the request to HTTP bridge fails due to a ``HTTPException`` exception and it is configured as ``silently=True``. """ # Artificially raise the ``HTTPException`` exception. api_call_mock.side_effect = HTTPException crossbar_client = Client('http://localhost:8001', timeout=5, silently=True) self.assertEqual( crossbar_client.publish('http://localhost:8001', 1234), None)
def test_publish(self): client = Client(self.url + "/publish", timeout=5) publish_id = client.publish("test.publish", 4, 7, event="new event") self.assertNotEqual(publish_id, None)
def test_no_call_params(self): client = Client(self.url + "/call", timeout=5) self.assertRaises(ClientMissingParams, client._make_api_call, "POST", client.url)
def test_call_exception(self): client = Client(self.url + "/call", timeout=5) self.assertRaises(ClientCallRuntimeError, client.call, "test.exception")
def setUp(self): self.crossbar_client = Client('http://localhost:8001', timeout=5)
def test_call(self): client = Client(self.url + "/call", timeout=5) result = client.call("test.add", 2, 3, offset=10) self.assertEqual(result, 15)