Esempio n. 1
0
    def test_get_layer_attribute_names(self):
        """Test we can get the correct attributes back"""
        layer = make_polygon_layer()

        # with good attribute name
        attributes, position = layer_attribute_names(
            layer, [QVariant.Int, QVariant.String],
            'TEST_STRIN')  # Not a typo...
        expected_attributes = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        expected_position = 2
        message = 'expected_attributes, got %s, expected %s' % (
            attributes, expected_attributes)
        assert (attributes == expected_attributes), message
        message = 'expected_position, got %s, expected %s' % (
            position, expected_position)
        assert (position == expected_position), message

        # with non existing attribute name
        attributes, position = layer_attribute_names(
            layer, [QVariant.Int, QVariant.String], 'MISSING_ATTR')
        expected_attributes = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        expected_position = None
        message = 'expected_attributes, got %s, expected %s' % (
            attributes, expected_attributes)
        assert (attributes == expected_attributes), message
        message = 'expected_position, got %s, expected %s' % (
            position, expected_position)
        assert (position == expected_position), message

        # with raster layer
        layer = make_padang_layer()
        attributes, position = layer_attribute_names(layer, [], '')
        message = 'Should return None, None for raster layer, got %s, %s' % (
            attributes, position)
        assert (attributes is None and position is None), message
Esempio n. 2
0
    def test_isLayerPolygonal(self):
        """Test we can get the correct attributes back"""
        layer = make_polygon_layer()
        message = 'isPolygonLayer, %s layer should be polygonal' % layer
        assert is_polygon_layer(layer), message

        layer = make_point_layer()
        message = '%s layer should be polygonal' % layer
        assert not is_polygon_layer(layer), message

        layer = make_padang_layer()
        message = ('%s raster layer should not be polygonal' % layer)
        assert not is_polygon_layer(layer), message
Esempio n. 3
0
    def test_getLayerAttributeNames(self):
        """Test we can get the correct attributes back"""
        layer = make_polygon_layer()

        #with good attribute name
        myAttrs, myPos = layer_attribute_names(layer, [
            QVariant.Int, QVariant.String],
            'TEST_STRIN')  # Not a typo...
        myExpectedAttrs = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        myExpectedPos = 2
        message = 'myExpectedAttrs, got %s, expected %s' % (
            myAttrs, myExpectedAttrs)
        assert (myAttrs == myExpectedAttrs), message
        message = 'myExpectedPos, got %s, expected %s' % (
            myPos, myExpectedPos)
        assert (myPos == myExpectedPos), message

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

        #with raster layer
        layer = make_padang_layer()
        myAttrs, myPos = layer_attribute_names(layer, [], '')
        message = 'Should return None, None for raster layer, got %s, %s' % (
            myAttrs, myPos)
        assert (myAttrs is None and myPos is None), message
Esempio n. 4
0
    def test_get_layer_attribute_names(self):
        """Test we can get the correct attributes back"""
        layer = make_polygon_layer()

        #with good attribute name
        attributes, position = layer_attribute_names(layer, [
            QVariant.Int, QVariant.String],
            'TEST_STRIN')  # Not a typo...
        expected_attributes = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        expected_position = 2
        message = 'expected_attributes, got %s, expected %s' % (
            attributes, expected_attributes)
        assert (attributes == expected_attributes), message
        message = 'expected_position, got %s, expected %s' % (
            position, expected_position)
        assert (position == expected_position), message

        #with non existing attribute name
        attributes, position = layer_attribute_names(
            layer,
            [QVariant.Int, QVariant.String],
            'MISSING_ATTR')
        expected_attributes = ['KAB_NAME', 'TEST_INT', 'TEST_STRIN']
        expected_position = None
        message = 'expected_attributes, got %s, expected %s' % (
            attributes, expected_attributes)
        assert (attributes == expected_attributes), message
        message = 'expected_position, got %s, expected %s' % (
            position, expected_position)
        assert (position == expected_position), message

        #with raster layer
        layer = make_padang_layer()
        attributes, position = layer_attribute_names(layer, [], '')
        message = 'Should return None, None for raster layer, got %s, %s' % (
            attributes, position)
        assert (attributes is None and position is None), message