def test_df_rows_order(self, mock_request):

        geocoding_result = Regions([
            self.foo.set_query('').build_geocoded(),
            self.bar.set_query('').build_geocoded(),
            self.baz.set_query('').build_geocoded(),
        ])

        mock_request.return_value = make_success_response() \
            .set_geocoded_features(
            [
                self.foo.set_query(self.bar_id).set_centroid(GeoPoint(0, 1)).build_geocoded(),
                self.bar.set_query(self.foo_id).set_centroid(GeoPoint(0, 1)).build_geocoded(),
                self.baz.set_query(self.baz_id).set_centroid(GeoPoint(0, 1)).build_geocoded(),
            ]
        ).build()

        df = geocoding_result.centroids()

        mock_request.assert_called_with(
            RequestBuilder() \
                .set_request_kind(RequestKind.explicit) \
                .set_ids([self.foo.id, self.bar.id, self.baz.id]) \
                .set_requested_payload([PayloadKind.centroids]) \
                .build()
        )

        assert [self.foo.name, self.bar.name,
                self.baz.name] == df[DF_REQUEST].tolist()
    def test_df_rows_duplication_should_be_processed_correctly(
            self, mock_request):
        foo_id = '123'
        foo_name = 'foo'

        bar_id = '234'
        bar_name = 'bar'

        geocoding_result = Regions([
            self.foo.set_query('').build_geocoded(),
            self.bar.set_query('').build_geocoded(),
            self.foo.set_query('').build_geocoded()
        ])

        mock_request.return_value = make_success_response() \
            .set_geocoded_features(
            [
                self.foo.set_query(foo_id).set_centroid(GeoPoint(0, 1)).build_geocoded(),
                self.bar.set_query(bar_id).set_centroid(GeoPoint(0, 1)).build_geocoded()
            ]
        ).build()

        df = geocoding_result.centroids()

        mock_request.assert_called_with(
            RequestBuilder() \
                .set_request_kind(RequestKind.explicit) \
                .set_ids([self.foo.id, self.bar.id]) \
                .set_requested_payload([PayloadKind.centroids]) \
                .build()
        )

        assert [self.foo.name, self.bar.name,
                self.foo.name] == df[DF_REQUEST].tolist()
    def test_df_request_when_query_is_empty_should_be_taken_from_found_name_column(
            self, mock_request):
        foo_id = '123'
        foo_name = 'foo'
        geocoding_result = Regions([
            FeatureBuilder().set_id(foo_id).set_query('').set_name(
                foo_name).build_geocoded()
        ])

        mock_request.return_value = make_success_response() \
            .set_geocoded_features(
            [
                FeatureBuilder().set_id(foo_id).set_query(foo_id).set_name(foo_name).set_centroid(GeoPoint(0, 1)).build_geocoded()
            ]
        ).build()

        df = geocoding_result.centroids()

        mock_request.assert_called_with(
            RequestBuilder() \
                .set_request_kind(RequestKind.explicit)
                .set_ids([foo_id]) \
                .set_requested_payload([PayloadKind.centroids]) \
                .build()
        )

        assert foo_name == df[DF_REQUEST][0]