def test_temporaryfile(): file = core.TemporaryFile() with file.open_file("read_only"): assert file.get_open_mode() == "read_only" date = core.DateTime(2000, 1, 1, 1, 1, 1) date.set_timezone("Europe/Berlin") # tzinfo=datetime.timezone.utc # print(str(date.get_timezone())) file.set_file_time(date, "birth") # assert file.get_file_time("birth") == date.get_value() with pytest.raises(InvalidParamError): file.set_file_time(date, "test")
def test_datetime(): dt = core.DateTime(2000, 11, 11, 0, 0, 0) with open("data.pkl", "wb") as jar: pickle.dump(dt, jar) with open("data.pkl", "rb") as jar: new = pickle.load(jar) assert dt == new dt.set_timezone("Europe/Berlin") tz = core.TimeZone("Europe/Berlin") dt.set_timezone(tz) assert dt.get_timezone() == tz assert dt.to_format("iso") == "2000-11-11T00:00:00+01:00" dt.get_date() dt.get_time() dt.set_time_spec("utc") with pytest.raises(InvalidParamError): dt.set_time_spec("test") assert dt.get_time_spec() == "utc"
def get_datetime(self) -> core.DateTime: return core.DateTime(self.dateTime())
def get_expiration(self) -> core.DateTime: return core.DateTime(self.expiration())
def get_last_modified(self) -> core.DateTime: return core.DateTime(self.lastModified())
def get_last_read(self) -> core.DateTime: return core.DateTime(self.lastRead())
def get_metadata_change_time(self) -> core.DateTime: return core.DateTime(self.metadataChangeTime())
def get_birth_time(self) -> core.DateTime: return core.DateTime(self.birthTime())
def get_timestamp(self) -> core.DateTime: return core.DateTime(self.timestamp())
def get_departure_time(self) -> core.DateTime: return core.DateTime(self.departureTime())
def get_last_visited(self) -> core.DateTime: return core.DateTime(self.lastVisited())