class TestMyDate(): @classmethod def setup_class(self): self.date1 = MyDate(2020, 12, 29) self.date2 = MyDate(2021, 1, 2) def test_constructor_with_text(self): date = MyDate(date_text='2020/12/31') assert date.datetime.date() == datetime(year=2020, month=12, day=31).date() def test_constructor_with_date(self): date = MyDate(2020, 12, 31) assert date.datetime.date() == datetime(year=2020, month=12, day=31).date() def test_date_text(self): assert self.date1.date_text == '2020/12/29' def test_smaller_then(self): assert self.date1.smaller_than(self.date2) == True assert self.date2.smaller_than(self.date1) == False def test_next_day(self): self.date1.next_day() assert self.date1.date_text == '2020/12/30'
def test_fill_empty_date_start_date_ealier_than_source(self): cmt_times = [ { 'times': 2, 'time': '2020/12/31' }, { 'times': 1, 'time': '2021/01/01' }, { 'times': 0, 'time': '2021/01/02' }, { 'times': 3, 'time': '2021/01/03' } ] start_date = MyDate(year=2020, month=12, day=28) end_date = MyDate(year=2021, month=1, day=3) res = self.model._ProjectCommitModel__fill_empty_date( cmt_times, start_date, end_date) expect = [ { 'times': 0, 'time': '2020/12/28' }, { 'times': 0, 'time': '2020/12/29' }, { 'times': 0, 'time': '2020/12/30' }, { 'times': 2, 'time': '2020/12/31' }, { 'times': 1, 'time': '2021/01/01' }, { 'times': 0, 'time': '2021/01/02' }, { 'times': 3, 'time': '2021/01/03' } ] assert res == expect
def test_get_interval_commit_times(self): start_date = MyDate(date_text='2020/12/30') end_date = MyDate(date_text='2021/01/02') res = self.model._ProjectCommitModel__get_interval_commit_times( start_date, end_date) expect = [ { 'times': 0, 'time': '2020/12/31' }, { 'times': 0, 'time': '2021/01/01' } ] assert res == expect
def test_constructor_with_date(self): date = MyDate(2020, 12, 31) assert date.datetime.date() == datetime(year=2020, month=12, day=31).date()
def test_constructor_with_text(self): date = MyDate(date_text='2020/12/31') assert date.datetime.date() == datetime(year=2020, month=12, day=31).date()
def setup_class(self): self.date1 = MyDate(2020, 12, 29) self.date2 = MyDate(2021, 1, 2)