File: test_xml.py

package info (click to toggle)
dosage 3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,400 kB
  • sloc: python: 12,703; sh: 55; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 836 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2020 Tobias Gruetzmacher

from lxml import html

from dosagelib.xml import NS

import httpmocks


tree = html.document_fromstring(httpmocks.content('zp-222'))


class TestXML:
    def xpath(self, path):
        return tree.xpath(path, namespaces=NS)

    def test_class_ext(self):
        assert len(self.xpath('//li[d:class("menu-item-3773")]')) == 1
        assert len(self.xpath('//ul[d:class("menu")]')) == 1
        assert len(self.xpath('//li[d:class("menu-item-object-custom")]')) == 2
        assert len(self.xpath('//li[d:class("menu-item")]')) == 25

    def test_class_start_ext(self):
        assert len(self.xpath('//li[d:class_start("menu-item-5")]')) == 5

    def test_re_ext(self):
        assert len(self.xpath(r'//img[re:test(@src, "posters.*jpg")]')) == 1