Esempio n. 1
0
    def setUp(self):
        self.bucket = DummyFeatureStorage().create_bucket('test')

        self.test_key = Key.make_key(
            bucket=self.bucket.bucket_name, name='alice')

        self.test_feature1 = Feature.build_from_geometry(
            'POINT (8 8)', properties=dict(x=8, y=8),
        )
        self.test_feature2 = Feature.build_from_geometry(
            'POINT (8 8)', properties=dict(x=8, y=8, z=8),
        )
Esempio n. 2
0
    def test_get_feature(self):
        test_key = Key.make_key(bucket=self.bucket.bucket_name, name='alice')
        test_feature1 = Feature.build_from_geometry(
            'POINT (8 8)', properties=dict(x=8, y=8),
        )

        entry = FeatureEntry(self.bucket)
        response = entry.put_feature(test_key, test_feature1)

        # get a feature
        response, feature = entry.get_feature(test_key)
        self.assertEqual(feature.key, test_key)
        self.assertTrue(feature.equals(test_feature1))
Esempio n. 3
0
    def test_delete_feature(self):
        test_key = Key.make_key(bucket=self.bucket.bucket_name, name='alice')
        test_feature1 = Feature.build_from_geometry(
            'POINT (8 8)', properties=dict(x=8, y=8),
        )

        entry = FeatureEntry(self.bucket)
        response = entry.put_feature(test_key, test_feature1)

        # delete a feature
        response = entry.delete_feature(test_key)
        self.assertIsInstance(response, Response)
        self.assertEqual(response.key, test_key)
        self.assertRaises(FeatureNotFound, entry.get_feature, test_key)
Esempio n. 4
0
    def test_buckets(self):
        self.storage.create_bucket('bob', srid=4326, overwrite=True)

        bucket = self.storage.get_bucket('bob')
        self.assertIsNotNone(bucket)

        test_key = Key.make_key(bucket='test_bucket', name='alice')
        test_feature = Feature.build_from_geometry(
            'POINT (8 8)', properties=dict(x=8, y=8),
        )

        visitor = FeatureEntry(bucket)

        response = visitor.put_feature(test_key, test_feature)

        response, feature = visitor.get_feature(test_key)
        self.assertTrue(feature.equals(test_feature))

        response = visitor.delete_feature(test_key)
        self.assertRaises(FeatureNotFound, visitor.get_feature, test_key)

        self.storage.delete_bucket('bob')
        self.assertRaises(BucketNotFound, self.storage.get_bucket, 'bob')