Exemplo n.º 1
0
    def test_duplicate(self):
        """Test the PropertyInList expression with a list containing
        duplicates.

        Test whether the generated query is correct and does not contain the
        duplicate entry twice.

        """
        l = ['a', 'a', 'b', 'c']
        l_output = ['a', 'b', 'c']

        query = PropertyInList('methode', l)
        xml = query.toXML()

        assert xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 3

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}PropertyIsEqualTo'

            propertyname = f.find('./{http://www.opengis.net/ogc}PropertyName')
            assert propertyname.text == 'methode'

            literal = f.find('./{http://www.opengis.net/ogc}Literal')
            assert literal.text in l

            l_output.remove(literal.text)

        assert len(l_output) == 0
Exemplo n.º 2
0
    def test(self):
        """Test the PropertyInList expression with a standard list.

        Test whether the generated query is correct.

        """
        l = ['a', 'b', 'c']

        query = PropertyInList('methode', l)
        xml = query.toXML()

        assert xml.tag == '{http://www.opengis.net/ogc}Or'
        assert len(list(xml)) == 3

        for f in xml:
            assert f.tag == '{http://www.opengis.net/ogc}PropertyIsEqualTo'

            propertyname = f.find('./{http://www.opengis.net/ogc}PropertyName')
            assert propertyname.text == 'methode'

            literal = f.find('./{http://www.opengis.net/ogc}Literal')
            assert literal.text in l

            l.remove(literal.text)

        assert len(l) == 0
Exemplo n.º 3
0
    def test_nolist(self):
        """Test the PropertyInList expression with a string instead of a list.

        Test whether a ValueError is raised.

        """
        with pytest.raises(ValueError):
            l = 'goed'
            PropertyInList('betrouwbaarheid', l)
Exemplo n.º 4
0
    def test_emptylist(self):
        """Test the PropertyInList expression with an empty list.

        Test whether a ValueError is raised.

        """
        with pytest.raises(ValueError):
            l = []
            PropertyInList('methode', l)
Exemplo n.º 5
0
    def test_tooshort_duplicate(self):
        """Test the PropertyInList expression with a list containing
        a two identical items.

        Test whether a ValueError is raised.

        """
        with pytest.raises(ValueError):
            l = ['a', 'a']
            PropertyInList('methode', l)
Exemplo n.º 6
0
    def test_tooshort(self):
        """Test the PropertyInList expression with a list containing
        a single item.

        Test whether a ValueError is raised.

        """
        with pytest.raises(ValueError):
            l = ['a']
            PropertyInList('methode', l)
Exemplo n.º 7
0
    def test_stable(self):
        """Test the PropertyInList expression with a standard list.

        Test whether the generated query is correct and stable.

        """
        l = ['a', 'b', 'c']

        for p in permutations(l):
            query = PropertyInList('methode', list(p))
            xml = query.toXML()

            assert clean_xml(etree.tostring(xml).decode('utf8')) == clean_xml(
                '<ogc:Or><ogc:PropertyIsEqualTo><ogc:PropertyName>methode</ogc'
                ':PropertyName><ogc:Literal>a</ogc:Literal></ogc'
                ':PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName'
                '>methode</ogc:PropertyName><ogc:Literal>b</ogc:Literal></ogc'
                ':PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName'
                '>methode</ogc:PropertyName><ogc:Literal>c</ogc:Literal></ogc'
                ':PropertyIsEqualTo></ogc:Or>')
Exemplo n.º 8
0
    def test_list_single(self):
        """Test the PropertyInList expression with a list containing
        a single item.

        Test whether the generated query is correct and does contain only a
        single PropertyIsEqualTo.

        """
        l = ['a']

        query = PropertyInList('methode', l)
        xml = query.toXML()

        assert xml.tag == '{http://www.opengis.net/ogc}PropertyIsEqualTo'

        propertyname = xml.find('./{http://www.opengis.net/ogc}PropertyName')
        assert propertyname.text == 'methode'

        literal = xml.find('./{http://www.opengis.net/ogc}Literal')
        assert literal.text in l

        l.remove(literal.text)
        assert len(l) == 0
Exemplo n.º 9
0
    def test_search_propertyinlist(self, mp_remote_describefeaturetype,
                                   mp_remote_wfs_feature, mp_dov_xml):
        """Test the search method with a PropertyInList query.

        Parameters
        ----------
        mp_remote_describefeaturetype : pytest.fixture
            Monkeypatch the call to a remote DescribeFeatureType.
        mp_remote_wfs_feature : pytest.fixture
            Monkeypatch the call to get WFS features.
        mp_dov_xml : pytest.fixture
            Monkeypatch the call to get the remote XML data.

        """
        self.get_search_object().search(
            query=PropertyInList(self.get_wfs_field(), ['a', 'b']))