def test_ignore_running(self, datadir, serve_file) -> None:
     url = serve_file(datadir / "old-event.ics")
     timestamp = dateutil.parser.parse("20040605T110000Z")
     # events are taken if start hits exactly the current time
     assert Calendar("test", url=url, timeout=3).check(timestamp) is not None
     timestamp = timestamp + timedelta(seconds=1)
     assert Calendar("test", url=url, timeout=3).check(timestamp) is None
    def test_limited_horizon(self, datadir, serve_file) -> None:
        timestamp = dateutil.parser.parse("20040101T000000Z")

        assert (
            Calendar(
                "test", url=serve_file(datadir / "after-horizon.ics"), timeout=3,
            ).check(timestamp)
            is None
        )

        assert (
            Calendar(
                "test", url=serve_file(datadir / "before-horizon.ics"), timeout=3,
            ).check(timestamp)
            is not None
        )
 def test_empty(self, datadir, serve_file) -> None:
     timestamp = dateutil.parser.parse("20050605T130000Z")
     assert (
         Calendar(
             "test", url=serve_file(datadir / "old-event.ics"), timeout=3,
         ).check(timestamp)
         is None
     )
    def test_select_earliest(self, datadir, serve_file) -> None:
        timestamp = dateutil.parser.parse("20040401T090000Z")
        desired_start = dateutil.parser.parse("20040405T110000Z")

        assert (
            Calendar(
                "test", url=serve_file(datadir / "multiple.ics"), timeout=3,
            ).check(timestamp)
            == desired_start
        )
    def test_smoke(self, datadir, serve_file) -> None:
        timestamp = dateutil.parser.parse("20040605T090000Z")
        desired_start = dateutil.parser.parse("20040605T110000Z")

        assert (
            Calendar(
                "test", url=serve_file(datadir / "old-event.ics"), timeout=3,
            ).check(timestamp)
            == desired_start
        )
示例#6
0
 def test_create(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]
                           url = url
                           username = user
                           password = pass
                           timeout = 42''')
     check = Calendar.create('name', parser['section'])
     assert check._url == 'url'
     assert check._username == 'user'
     assert check._password == 'pass'
     assert check._timeout == 42
 def test_create(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         url = url
         username = user
         password = pass
         timeout = 42
         """
     )
     check: Calendar = Calendar.create(
         "name", parser["section"],
     )  # type: ignore
     assert check._url == "url"
     assert check._username == "user"
     assert check._password == "pass"
     assert check._timeout == 42
 def create_instance(self, name: str) -> Calendar:
     return Calendar(name, url="file:///asdf", timeout=3)
示例#9
0
 def test_ignore_running(self, stub_server):
     address = stub_server.resource_address('old-event.ics')
     timestamp = dateutil.parser.parse('20040605T120000Z')
     assert Calendar('test', url=address,
                     timeout=3).check(timestamp) is None
示例#10
0
 def test_smoke(self, stub_server):
     address = stub_server.resource_address('old-event.ics')
     timestamp = dateutil.parser.parse('20040605T090000Z')
     desired_start = dateutil.parser.parse('20040605T110000Z')
     assert Calendar('test', url=address,
                     timeout=3).check(timestamp) == desired_start
示例#11
0
 def create_instance(self, name):
     return Calendar(name, url='file:///asdf', timeout=3)