def test_single_lookup_values_correctly_assigned_to_parameters(self):
        sender = RequestCapturingSender()
        serializer = FakeDeserializer({})
        client = Client(sender, serializer)
        lookup = Lookup()

        lookup.street = '0'
        lookup.street2 = '1'
        lookup.secondary = '2'
        lookup.city = '3'
        lookup.state = '4'
        lookup.zipcode = '5'
        lookup.lastline = '6'
        lookup.addressee = '7'
        lookup.urbanization = '8'
        lookup.match = match_type.INVALID
        lookup.candidates = '9'

        client.send_lookup(lookup)

        self.assertEqual('0', sender.request.parameters['street'])
        self.assertEqual('1', sender.request.parameters['street2'])
        self.assertEqual('2', sender.request.parameters['secondary'])
        self.assertEqual('3', sender.request.parameters['city'])
        self.assertEqual('4', sender.request.parameters['state'])
        self.assertEqual('5', sender.request.parameters['zipcode'])
        self.assertEqual('6', sender.request.parameters['lastline'])
        self.assertEqual('7', sender.request.parameters['addressee'])
        self.assertEqual('8', sender.request.parameters['urbanization'])
        self.assertEqual(match_type.INVALID,
                         sender.request.parameters['match'])
        self.assertEqual('9', sender.request.parameters['candidates'])
    def test_empty_batch_not_sent(self):
        sender = RequestCapturingSender()
        client = Client(sender, None)

        client.send_batch(Batch())

        self.assertIsNone(sender.request)
    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_single_lookup_values_correctly_assigned_to_parameters(self):
        sender = RequestCapturingSender()
        serializer = FakeDeserializer({})
        client = Client(sender, serializer)
        lookup = Lookup()

        lookup.city = '0'
        lookup.state = '1'
        lookup.zipcode = '2'

        client.send_lookup(lookup)

        self.assertEqual('0', sender.request.parameters['city'])
        self.assertEqual('1', sender.request.parameters['state'])
        self.assertEqual('2', sender.request.parameters['zipcode'])