def test_datetime_to_zkctime__should_convert_datetime(self, value, expect): assert ZKDatetimeUtils.datetime_to_zkctime(value) == expect
def test_datetime_to_zkctime__if_date_less_than_2000_year__should_raise_error(self): with pytest.raises(ValueError): ZKDatetimeUtils.datetime_to_zkctime(datetime(1999, 12, 31, 23, 59, 59))
def test_datetime_to_zktimemoment__should_convert_to_zktimemoment(self, value, expect): assert ZKDatetimeUtils.datetime_to_zktimemoment(value) == expect
def test_zkctime_to_datetime__if_value_is_negative__should_raise_error(self): with pytest.raises(ValueError): ZKDatetimeUtils.zkctime_to_datetime(-1)
def test_zktimemoment_to_datetime__on_bad_value_type__should_raise_error(self, value): with pytest.raises(TypeError): ZKDatetimeUtils.zktimemoment_to_datetime(value)
def test_zktimemoment_to_datetime__on_bad_value__should_raise_error(self): with pytest.raises(ValueError): ZKDatetimeUtils.zktimemoment_to_datetime('')
def test_date_to_zkdate__should_convert_to_zkdate(self, value): assert ZKDatetimeUtils.date_to_zkdate(value) == '20200412'
def test_zktimemoment_to_datetime__on_empty_value__should_return_none(self): assert ZKDatetimeUtils.zktimemoment_to_datetime(0) is None
def test_zkdate_to_date__should_convert_to_date(self): assert ZKDatetimeUtils.zkdate_to_date('20200412') == date(2020, 4, 12)
def test_zkdate_to_date__on_empty_value__should_return_none(self): assert ZKDatetimeUtils.zkdate_to_date('0') is None
def test_times_to_zktimerange__should_convert_to_zktimerange(self, value, expect): assert ZKDatetimeUtils.times_to_zktimerange(*value) == expect
def test_zktimerange_to_times__if_value_less_that_zero__should_raise_error(self): with pytest.raises(ValueError): ZKDatetimeUtils.zktimerange_to_times(-1)
def test_zktimerange_to_times__should_convert_to_time_ranges(self, value, expect): assert ZKDatetimeUtils.zktimerange_to_times(value) == expect
def test_time_string_to_datetime__if_value_is_invalid__should_raise_error(self, value): with pytest.raises(ValueError): ZKDatetimeUtils.time_string_to_datetime(value)
def test_time_string_to_datetime__should_convert_datetime(self, value, expect): assert ZKDatetimeUtils.time_string_to_datetime(value) == expect