Ejemplo n.º 1
0
    def test_iterator(self):
        for test_case in self.test_cases:
            with self.subTest(msg='Test case {}'.format(test_case.name)):
                params = test_case.request
                gpd_iter = GeopediaFeatureIterator(**params)

                for idx, feature in enumerate(gpd_iter):
                    self.assertTrue(
                        isinstance(feature, dict),
                        'Expected at dictionary, got {}'.format(type(feature)))

                    if idx >= test_case.min_features - 1:
                        break

                self.assertEqual(
                    gpd_iter.index, test_case.min_features,
                    'Expected at least {} features, got {}'.format(
                        test_case.min_features, gpd_iter.index))

                if test_case.min_size:
                    self.assertTrue(
                        test_case.min_size <= len(gpd_iter),
                        'There should be at least {} features available, '
                        'got {}'.format(test_case.min_size,
                                        gpd_iter.get_size()))
Ejemplo n.º 2
0
    def test_size_before_iteration(self):
        for test_case in self.test_cases:
            if not test_case.min_features:
                continue

            with self.subTest(msg='Test case {}'.format(test_case.name)):
                params = test_case.request

                gpd_iter1 = GeopediaFeatureIterator(**params)
                _ = gpd_iter1.get_size()
                first_feature1 = next(gpd_iter1)

                gpd_iter2 = GeopediaFeatureIterator(**params)
                first_feature2 = next(gpd_iter2)

                self.assertEqual(first_feature1, first_feature2)