def test_create_not_numeric(self): parser = configparser.ConfigParser() parser.read_string('''[section] unit=seconds value=asdfasd''') with pytest.raises(ConfigurationError): Periodic.create('name', parser['section'])
def test_create_wrong_unit(self): parser = configparser.ConfigParser() parser.read_string('''[section] unit=asdfasdf value=13''') with pytest.raises(ConfigurationError): Periodic.create('name', parser['section'])
def test_create_float(self) -> None: parser = configparser.ConfigParser() parser.read_string( """ [section] unit=seconds value=21312.12 """ ) Periodic.create("name", parser["section"])
def test_create_no_unit(self) -> None: parser = configparser.ConfigParser() parser.read_string( """ [section] value=asdfasd """ ) with pytest.raises(ConfigurationError): Periodic.create("name", parser["section"])
def test_create(self): parser = configparser.ConfigParser() parser.read_string('''[section] unit=seconds value=13''') check = Periodic.create('name', parser['section']) assert check._delta == timedelta(seconds=13)
def test_create(self) -> None: parser = configparser.ConfigParser() parser.read_string( """ [section] unit=seconds value=13 """ ) check = Periodic.create("name", parser["section"]) assert check._delta == timedelta(seconds=13)
def test_check(self) -> None: delta = timedelta(seconds=10, minutes=42) check = Periodic("test", delta) now = datetime.now(timezone.utc) assert check.check(now) == now + delta
def create_instance(self, name): delta = timedelta(seconds=10, minutes=42) return Periodic(name, delta)
def test_create_float(self): parser = configparser.ConfigParser() parser.read_string('''[section] unit=seconds value=21312.12''') Periodic.create('name', parser['section'])