Example #1
0
    def test_centroids(self, mock_request):
        try:
            self.make_regions().centroids()
        except ValueError:
            pass  # response doesn't contain proper feature with ids - ignore

        mock_request.assert_called_with(
            ExplicitRequest(requested_payload=[PayloadKind.centroids],
                            ids=[USA_ID, RUSSIA_ID]))
Example #2
0
    def test_boundaries(self, mock_request):
        try:
            self.make_regions().boundaries(resolution=RESOLUTION)
        except ValueError:
            pass  # response doesn't contain proper feature with ids - ignore

        mock_request.assert_called_with(
            ExplicitRequest(requested_payload=[PayloadKind.boundaries],
                            ids=[USA_ID, RUSSIA_ID],
                            resolution=_to_resolution(RESOLUTION)))
Example #3
0
def test_geocode_limit(mock_request):
    try:
        make_geocode_region(REQUEST, REGION_NAME, REGION_ID,
                            REGION_HIGHLIGHTS).limits()
    except ValueError:
        pass  # response doesn't contain proper feature with ids - ignore

    mock_request.assert_called_with(
        ExplicitRequest(requested_payload=[PayloadKind.limits],
                        ids=REGION_LIST))
Example #4
0
def test_geocode_boundary(mock_request):
    try:
        make_geocode_region(REQUEST, REGION_NAME, REGION_ID,
                            REGION_HIGHLIGHTS).boundaries(RESOLUTION)
    except ValueError:
        pass  # response doesn't contain proper feature with ids - ignore

    mock_request.assert_called_with(
        ExplicitRequest(requested_payload=[PayloadKind.boundaries],
                        ids=REGION_LIST,
                        resolution=_to_resolution(RESOLUTION)))
Example #5
0
def test_request_remove_duplicated_ids(mock_request):
    try:
        Regions([
            make_region(REQUEST, REGION_NAME, REGION_ID, REGION_HIGHLIGHTS),
            make_region(REQUEST, REGION_NAME, REGION_ID, REGION_HIGHLIGHTS)
        ]).centroids()
    except ValueError:
        pass  # response doesn't contain proper feature with ids - ignore

    mock_request.assert_called_with(
        ExplicitRequest(requested_payload=[PayloadKind.centroids],
                        ids=[REGION_ID]))
Example #6
0
def test_request_remove_duplicated_ids(mock_request):
    try:
        Geocodes(
            level_kind=LEVEL_KIND,
            queries=features_to_queries([FOO_FEATURE, FOO_FEATURE]),
            answers=features_to_answers([FOO_FEATURE, FOO_FEATURE])
        ).centroids()
    except ValueError:
        pass  # response doesn't contain proper feature with ids - ignore

    mock_request.assert_called_with(
        ExplicitRequest(
            requested_payload=[PayloadKind.centroids],
            ids=[FOO_FEATURE.id]
        )
    )