def test__format_date_ok(self): ''' test _format_date with valid format ''' ret = cleanup_clicrdv._format_date('20180621') self.assertEquals(ret, datetime.date(2018, 6, 21))
def test__format_date_year_only(self): ''' test _format_date with year only ''' ret = cleanup_clicrdv._format_date('2017') self.assertEquals(ret, datetime.date(2017, 1, 1))
def test__format_date_invalid_day_format(self): ''' test _format_date with invalid day format ''' ret = cleanup_clicrdv._format_date('201806yz') self.assertEquals(ret, None) output = sys.stdout.getvalue().strip() self.assertEquals(output, 'Invalid day format : yz')
def test__format_date_invalid_month_range(self): ''' test _format_date with invalid month range ''' ret = cleanup_clicrdv._format_date('20182106') self.assertEquals(ret, None) output = sys.stdout.getvalue().strip() self.assertEquals(output, 'Invalid month range : 21')
def test__format_date_invalid_month_format(self): ''' test _format_date with invalid month format ''' ret = cleanup_clicrdv._format_date('2018/21/06') self.assertEquals(ret, None) output = sys.stdout.getvalue().strip() self.assertEquals(output, 'Invalid month format : /2')
def test__format_date_invalid_year_range(self): ''' test _format_date with invalid year range ''' ret = cleanup_clicrdv._format_date('10000621') self.assertEquals(ret, None) output = sys.stdout.getvalue().strip() self.assertEquals(output, 'Invalid year range : 1000')
def test__format_date_invalid_year_format(self): ''' test _format_date with invalid year format ''' ret = cleanup_clicrdv._format_date('18/06/21') self.assertEquals(ret, None) output = sys.stdout.getvalue().strip() self.assertEquals(output, 'Invalid year format : 18/0')