def test_date_time_to_string(): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time.to_string() assert date_time.to_string(DateTime.Format.Standard) assert date_time.to_string(DateTime.Format.ISO8601) assert date_time.to_string(DateTime.Format.STK)
def test_environment_constructors (): instant = Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC) objects = [] env: Environment = Environment(instant, objects) assert env is not None assert isinstance(env, Environment)
def test_date_time_comparators(): date_time_1 = DateTime(2020, 1, 1, 0, 0, 0, 0, 0, 0) date_time_2 = DateTime(2020, 1, 1, 0, 0, 0, 0, 0, 1) date_time_3 = DateTime(2020, 1, 1, 0, 0, 1, 0, 0, 0) assert date_time_1 == date_time_1 assert date_time_2 == date_time_2 assert date_time_3 == date_time_3 assert date_time_1 != date_time_2 assert date_time_1 != date_time_3 date_time_1: DateTime = DateTime(2020, 1, 2, 3, 4, 5) date_time_2: DateTime = datetime.datetime(2020, 1, 2, 3, 4, 5) assert date_time_1 == date_time_1 assert date_time_1 == date_time_2 assert date_time_2 == date_time_2 assert (date_time_1 != date_time_1) is False
def test_date_time_constructors(): # Construction with 6 integers in input date_time: DateTime = DateTime(2020, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time is not None assert isinstance(date_time, DateTime) assert date_time.is_defined() # Construction with 9 integers in input date_time: DateTime = DateTime(2020, 1, 1, 0, 0, 0) assert date_time is not None assert isinstance(date_time, DateTime) assert date_time.is_defined() # Construction with Date and Time objects date_time: DateTime = DateTime(Date(2020, 1, 1), Time(0, 0, 0)) assert date_time is not None assert isinstance(date_time, DateTime) assert date_time.is_defined()
def test_environment_constructors(): instant = Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC) objects = [] assert Environment(instant, objects) is not None
def test_environment_setInstant(): environment = Environment.default() environment.set_instant( Instant.date_time(DateTime(2019, 1, 1, 0, 0, 0), Scale.UTC))
def test_date_time_get_modified_julian_date(): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time.get_modified_julian_date()
def test_date_time_get_time(): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time.get_time() is not None assert date_time.get_time() == Time(0, 0, 0, 0, 0, 0)
def test_date_time_is_defined(): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time is not None assert date_time.is_defined()
def test_date_time_parse(): ## Using python strings # Testing with default argument (DateTime.Format.Undefined) date_time = DateTime.parse('2018-01-01 00:00:00') assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.Standard date_time = DateTime.parse('2018-01-01 00:00:00', DateTime.Format.Standard) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.ISO8601 date_time = DateTime.parse('2018-01-01T00:00:00', DateTime.Format.ISO8601) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.STK date_time = DateTime.parse('1 Jan 2018 00:00:00', DateTime.Format.STK) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) ## Using String # Testing with default argument (DateTime.Format.Undefined) date_time = DateTime.parse(String('2018-01-01 00:00:00')) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.Standard date_time = DateTime.parse(String('2018-01-01 00:00:00'), DateTime.Format.Standard) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.ISO8601 date_time = DateTime.parse(String('2018-01-01T00:00:00'), DateTime.Format.ISO8601) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) # Testing with DateTime.Format.STK date_time = DateTime.parse(String('1 Jan 2018 00:00:00'), DateTime.Format.STK) assert date_time is not None assert isinstance(date_time, datetime.datetime) assert date_time == datetime.datetime(2018, 1, 1, 0, 0) assert date_time == DateTime(2018, 1, 1, 0, 0, 0) assert (datetime.datetime.now() + datetime.timedelta(days=1)) is not None
def test_date_time_get_date (): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert date_time.get_date()
def test_date_time_operators (): date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) assert (date_time == date_time) is not None assert (date_time != date_time) is not None
def test_date_time_constructors (): assert DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0) is not None assert DateTime(2018, 1, 1, 0, 0, 0) is not None assert DateTime(Date(2018, 1, 1), Time(0, 0, 0)) is not None
def test_instant_datetime (): assert Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0), Scale.UTC) is not None assert Instant.date_time(datetime.datetime.now(), Scale.UTC)