Exemplo n.º 1
0
    def test_put_feature_with_same_key_without_revision(self):
        entry = FeatureEntry(self.bucket)
        response = entry.put_feature(self.test_key, self.test_feature1)
        response = entry.put_feature(self.test_key, self.test_feature2)

        self.assertIsInstance(response, Response)
        self.assertEqual(response.key, self.test_key)

        response, feature = entry.get_feature(self.test_key)
        self.assertEqual(feature.key, self.test_key)
        self.assertTrue(feature.equals(self.test_feature2))
Exemplo 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))
Exemplo 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)
Exemplo 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')
Exemplo n.º 5
0
    def test_put_feature_without_revision(self):
        entry = FeatureEntry(self.bucket)
        response = entry.put_feature(self.test_key, self.test_feature1)

        self.assertIsInstance(response, Response)
        self.assertEqual(response.key, self.test_key)