Exemplo n.º 1
0
    def test_update(self):
        from c2cgeoportal.views.layers import update

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u'__test_user')
        request.matchdict['feature_id'] = 1
        request.method = 'PUT'
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c2é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # NOQA
        feature = update(request)
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, 'foobar')
        self.assertEquals(feature.child, u'c2é')
Exemplo n.º 2
0
    def test_update(self):
        from c2cgeoportal.views.layers import update

        layer_id = self._create_layer()
        request = self._get_request(layer_id, username=u'__test_user')
        request.matchdict['feature_id'] = 1
        request.method = 'PUT'
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c2é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # NOQA
        feature = update(request)
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, 'foobar')
        self.assertEquals(feature.child, u'c2é')
Exemplo n.º 3
0
    def test_update_and_read_public(self):
        import transaction
        from c2cgeoportal.views.layers import update, read_one

        layer_id = self._create_layer(public=True)

        request = self._get_request(layer_id)
        request.matchdict['feature_id'] = 1
        request.method = 'PUT'
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c1é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # NOQA
        feature = update(request)
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, 'foobar')
        self.assertEquals(feature.child, u'c1é')

        transaction.commit()

        request = self._get_request(layer_id)
        request.matchdict['feature_id'] = 1
        feature = read_one(request)
        self.assertEquals(feature.properties['child'], u'c1é')
Exemplo n.º 4
0
    def test_update_and_read_public(self):
        import transaction
        from c2cgeoportal.views.layers import update, read_one

        layer_id = self._create_layer(public=True)

        request = self._get_request(layer_id)
        request.matchdict['feature_id'] = 1
        request.method = 'PUT'
        request.body = '{"type": "Feature", "id": 1, "properties": {"name": "foobar", "child": "c1é"}, "geometry": {"type": "Point", "coordinates": [5, 45]}}'  # NOQA
        feature = update(request)
        self.assertEquals(feature.id, 1)
        self.assertEquals(feature.name, 'foobar')
        self.assertEquals(feature.child, u'c1é')

        transaction.commit()

        request = self._get_request(layer_id)
        request.matchdict['feature_id'] = 1
        feature = read_one(request)
        self.assertEquals(feature.properties['child'], u'c1é')