def test_date_yyyymmdd_hh(self): u""" Test with a date that is formatted "YYYYMMDD.hh". ValueError is thrown because its format is invalid. """ with self.assertRaises(ValueError): set_android_date.parse_date('20110510.02')
def test_invalid_date(self): u""" Test when invalid date. ValueError is thrown. """ with self.assertRaises(ValueError): set_android_date.parse_date('abcde')
def check_converting_seconds(self, date_string, date_format): u""" Check a string that represents date and its converted seconds are equal. """ seconds = set_android_date.parse_date(date_string) self.assertEquals(date_string, self.convert_to_string(seconds, date_format))
def test_now(self): u""" Test parsing a string that represents now. Seconds represents parsing time. """ previous_called_time = self.get_current_time() seconds = set_android_date.parse_date(set_android_date.DATE_NOW) after_called_time = self.get_current_time() self.assertTrue(previous_called_time <= seconds) self.assertTrue(seconds <= after_called_time)