예제 #1
0
 def test_set_schema_dict(self):
     "Check schema can be set on filter class with a dict"
     schema = Schema({Required('is_multi'): True}, extra=ALLOW_EXTRA)
     filt = FeatureFilter(schema={'is_multi': True})
     filt2 = FeatureFilter()
     filt2.schema = {'is_multi': True}
     self.assertEqual(schema, filt.schema)
     self.assertEqual(schema, filt2.schema)
     self.assertEqual(filt.schema, filt2.schema)
예제 #2
0
 def test_set_schema(self):
     "Check schema can be set on filter class"
     schema = Schema({Required('id'): All(int, Range(min=2, max=4))},
                     extra=ALLOW_EXTRA)
     filt = FeatureFilter(schema=schema)
     filt2 = FeatureFilter()
     filt2.schema = schema
     self.assertEqual(schema, filt.schema)
     self.assertEqual(schema, filt2.schema)
     self.assertEqual(filt.schema, filt2.schema)
예제 #3
0
 def test_set_schema_dict_2(self):
     "Check schema can be set on filter class with a dict"
     filt = FeatureFilter(schema={'is_multi': True})
     output = FeatureCollection(filt(FCOLLECTION))
     self.assertEqual(len(output), 3)
     for feature in output:
         self.assertTrue(feature.properties['is_multi'])
         self.assertTrue(feature.properties['id'] in {2, 5, 6})
예제 #4
0
 def test_filter_schema(self):
     "Check we can filter with a schema"
     schema = Schema({Required('id'): All(int, Range(min=2, max=4))},
                     extra=ALLOW_EXTRA)
     filt = FeatureFilter(schema=schema)
     output = FeatureCollection(filt(FCOLLECTION))
     self.assertEqual(len(output), 3)
     for feature in output:
         self.assertTrue(feature.properties['id'] >= 2)
         self.assertTrue(feature.properties['id'] <= 4)
예제 #5
0
 def test_filter_chunk(self, length):
     "Check we can filter in chunks"
     filt = FeatureFilter(chunk=length)
     for output in filt(FCOLLECTION):
         self.assertEqual(len(output), length)
예제 #6
0
 def test_filter_limit(self, length):
     "Check we can filter with a given limit"
     filt = FeatureFilter(limit=length)
     output = FeatureCollection(filt(FCOLLECTION))
     self.assertEqual(len(output), length)
예제 #7
0
 def test_filter_single_property(self):
     "Validation without a schema returns all features"
     filt = FeatureFilter(keep_properties='id')
     for orig, filtered in zip(FCOLLECTION, filt(FCOLLECTION)):
         self.assertEqual(orig.properties['id'], filtered.properties['id'])
         self.assertNotIn('is_multi', filtered.properties.keys())
예제 #8
0
 def test_filter_no_properties(self):
     "Validation without a schema returns all features"
     filt = FeatureFilter(keep_properties=True)
     for orig, filtered in zip(FCOLLECTION, filt(FCOLLECTION)):
         self.assertEqual(orig, filtered)
예제 #9
0
 def test_filter_all_properties(self):
     "Validation without a schema returns all features"
     filt = FeatureFilter(keep_properties=False)
     for feature in filt(FCOLLECTION):
         self.assertEqual(feature.properties, None)
예제 #10
0
 def test_filter_no_schema(self):
     "Validation without a schema returns all features"
     filt = FeatureFilter()
     valid = FeatureCollection(filt.validate(FCOLLECTION))
     self.assertEqual(FCOLLECTION, valid)