def test_create_wrong_unit(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         xpath=/valid
         url=nourl
         timeout=20
         unit=unknown
         """
     )
     with pytest.raises(ConfigurationError):
         XPathDelta.create("name", parser["section"])
Esempio n. 2
0
 def test_init_wrong_unit(self):
     with pytest.raises(ValueError):
         XPathDelta('name',
                    url='url',
                    xpath='/a',
                    timeout=5,
                    unit='unknownunit')
Esempio n. 3
0
 def test_create(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]
                        xpath=/valid
                        url=nourl
                        timeout=20
                        unit=weeks''')
     check = XPathDelta.create('name', parser['section'])
     assert check._unit == 'weeks'
 def test_create(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         xpath=/valid
         url=nourl
         timeout=20
         unit=weeks
         """
     )
     check = XPathDelta.create("name", parser["section"])
     assert check._unit == "weeks"
    def test_smoke(self, mocker, unit, factor) -> None:
        mock_reply = mocker.MagicMock()
        content_property = mocker.PropertyMock()
        type(mock_reply).content = content_property
        content_property.return_value = '<a value="42"></a>'
        mocker.patch("requests.Session.get", return_value=mock_reply)

        url = "nourl"
        now = datetime.now(timezone.utc)
        result = XPathDelta(
            "foo", xpath="/a/@value", url=url, timeout=5, unit=unit
        ).check(now)
        assert result == now + timedelta(seconds=42) * factor
 def test_init_wrong_unit(self) -> None:
     with pytest.raises(ValueError):
         XPathDelta("name", url="url", xpath="/a", timeout=5, unit="unknownunit")
 def create_instance(self, name):
     return XPathDelta(name, xpath="/a", url="nourl", timeout=5, unit="days")
Esempio n. 8
0
 def create_instance(self, name):
     return XPathDelta(name,
                       xpath='/a',
                       url='nourl',
                       timeout=5,
                       unit='days')