Beispiel #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
Beispiel #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
Beispiel #3
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>')
Beispiel #4
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