示例#1
0
 def test_init_wrong_unit(self):
     with pytest.raises(ValueError):
         XPathDelta('name',
                    url='url',
                    xpath='/a',
                    timeout=5,
                    unit='unknownunit')
    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")
示例#5
0
 def create_instance(self, name):
     return XPathDelta(name,
                       xpath='/a',
                       url='nourl',
                       timeout=5,
                       unit='days')