def test_successfully_sends_batch(self): expected_payload = "Hello, World!" sender = RequestCapturingSender() serializer = FakeSerializer(expected_payload) client = Client(sender, serializer) batch = Batch() batch.add(Lookup()) batch.add(Lookup()) client.send_batch(batch) self.assertEqual(expected_payload, sender.request.payload)
def test_raises_exception_when_response_has_error(self): exception = exceptions.BadCredentialsError client = Client(MockExceptionSender(exception), FakeSerializer(None)) self.assertRaises(exception, client.send_lookup, Lookup())