def test_isLayerPolygonal(self):
        """Test we can get the correct attributes back"""
        myLayer = makePolygonLayer()
        myMessage = 'isPolygonLayer, %s layer should be polygonal' % myLayer
        assert isPolygonLayer(myLayer), myMessage

        myLayer = makePointLayer()
        myMessage = '%s layer should be polygonal' % myLayer
        assert not isPolygonLayer(myLayer), myMessage

        myLayer = makePadangLayer()
        myMessage = ('%s raster layer should not be polygonal' % myLayer)
        assert not isPolygonLayer(myLayer), myMessage
예제 #2
0
    def test_isLayerPolygonal(self):
        """Test we can get the correct attributes back"""
        myLayer = makePolygonLayer()
        myMessage = 'isPolygonLayer, %s layer should be polygonal' % myLayer
        assert isPolygonLayer(myLayer), myMessage

        myLayer = makePointLayer()
        myMessage = '%s layer should be polygonal' % myLayer
        assert not isPolygonLayer(myLayer), myMessage

        myLayer = makePadangLayer()
        myMessage = ('%s raster layer should not be polygonal' % myLayer)
        assert not isPolygonLayer(myLayer), myMessage
    def test_getLayerAttributeNames(self):
        """Test we can get the correct attributes back"""
        myLayer = makePolygonLayer()

        #with good attribute name
        myAttrs, myPos = getLayerAttributeNames(myLayer, [
            QVariant.Int, QVariant.String],
            'TEST_STRIN')
        myExpectedAttrs = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        myExpectedPos = 2
        myMessage = 'myExpectedAttrs, got %s, expected %s' % (
            myAttrs, myExpectedAttrs)
        assert (myAttrs == myExpectedAttrs), myMessage
        myMessage = 'myExpectedPos, got %s, expected %s' % (
            myPos, myExpectedPos)
        assert (myPos == myExpectedPos), myMessage

        #with inexistent attribute name
        myAttrs, myPos = getLayerAttributeNames(
            myLayer,
            [QVariant.Int, QVariant.String],
            'MISSING_ATTR')
        myExpectedAttrs = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        myExpectedPos = None
        myMessage = 'myExpectedAttrs, got %s, expected %s' % (
            myAttrs, myExpectedAttrs)
        assert (myAttrs == myExpectedAttrs), myMessage
        myMessage = 'myExpectedPos, got %s, expected %s' % (
            myPos, myExpectedPos)
        assert (myPos == myExpectedPos), myMessage

        #with raster layer
        myLayer = makePadangLayer()
        myAttrs, myPos = getLayerAttributeNames(myLayer, [], '')
        myMessage = 'Should return None, None for raster layer, got %s, %s' % (
            myAttrs, myPos)
        assert (myAttrs is None and myPos is None), myMessage
예제 #4
0
    def test_getLayerAttributeNames(self):
        """Test we can get the correct attributes back"""
        myLayer = makePolygonLayer()

        #with good attribute name
        myAttrs, myPos = getLayerAttributeNames(myLayer, [
            QVariant.Int, QVariant.String],
            'TEST_STRIN')
        myExpectedAttrs = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        myExpectedPos = 2
        myMessage = 'myExpectedAttrs, got %s, expected %s' % (
            myAttrs, myExpectedAttrs)
        assert (myAttrs == myExpectedAttrs), myMessage
        myMessage = 'myExpectedPos, got %s, expected %s' % (
            myPos, myExpectedPos)
        assert (myPos == myExpectedPos), myMessage

        #with inexistent attribute name
        myAttrs, myPos = getLayerAttributeNames(
            myLayer,
            [QVariant.Int, QVariant.String],
            'MISSING_ATTR')
        myExpectedAttrs = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        myExpectedPos = None
        myMessage = 'myExpectedAttrs, got %s, expected %s' % (
            myAttrs, myExpectedAttrs)
        assert (myAttrs == myExpectedAttrs), myMessage
        myMessage = 'myExpectedPos, got %s, expected %s' % (
            myPos, myExpectedPos)
        assert (myPos == myExpectedPos), myMessage

        #with raster layer
        myLayer = makePadangLayer()
        myAttrs, myPos = getLayerAttributeNames(myLayer, [], '')
        myMessage = 'Should return None, None for raster layer, got %s, %s' % (
            myAttrs, myPos)
        assert (myAttrs is None and myPos is None), myMessage