Esempio n. 1
0
 def test_will_raise_an_TypeError_if_timestamp_is_not_an_integer_with_safe_parameter_set_to_False(
         self):
     with self.assertRaises(TypeError):
         Timelapsed.from_timestamp('sdfsdfsf3434534erftg', safe=False)
Esempio n. 2
0
 def test_59_minutes_ago_default_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          59000 * 60,
                                          notation='mid')
     self.assertEqual(duration, '59mins')
Esempio n. 3
0
 def test_3_weeks_ago_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          3000 * 60 * 60 * 24 * 7,
                                          notation='lng')
     self.assertEqual(duration, '3 weeks ago')
Esempio n. 4
0
 def test_will_return_VE_if_timestamp_is_out_of_range_with_safe_parameter_left_as_default_True_and_debug_parameter_left_as_default_False(
         self):
     duration = Timelapsed.from_timestamp(324324234242424)
     self.assertEqual(duration, 'V/E')
Esempio n. 5
0
 def test_17_minutes_ago_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          17000 * 60,
                                          notation='lng')
     self.assertEqual(duration, '17 minutes ago')
Esempio n. 6
0
 def test_just_now_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='mid')
     self.assertEqual(duration, 'now')
Esempio n. 7
0
 def test_1_minute_ago_default_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60)
     self.assertEqual(duration, '1 minute ago')
Esempio n. 8
0
 def test_1_day_ago_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60 * 60 * 24,
                                          notation='lng')
     self.assertEqual(duration, 'yesterday')
Esempio n. 9
0
 def test_6_days_ago_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          6000 * 60 * 60 * 24,
                                          notation='mid')
     self.assertEqual(duration, '6dys')
Esempio n. 10
0
 def test_1_day_ago_twitter_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60 * 60 * 24,
                                          notation='twitter')
     self.assertEqual(duration, '1d')
Esempio n. 11
0
 def test_will_return_NA_if_timestamp_is_not_an_integer_with_safe_parameter_left_as_default_True_and_debug_parameter_is_set_to_True(
         self):
     duration = Timelapsed.from_timestamp('sdfsdfsf4435435rete', debug=True)
     self.assertEqual(duration, 'N/A')
Esempio n. 12
0
 def test_19_hours_ago_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          19000 * 60 * 60,
                                          notation='lng')
     self.assertEqual(duration, '19 hours ago')
Esempio n. 13
0
 def test_19_hours_ago_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          19000 * 60 * 60,
                                          notation='mid')
     self.assertEqual(duration, '19hrs')
Esempio n. 14
0
 def test_will_return_TE_if_timestamp_is_not_an_integer_with_safe_parameter_left_as_default_True_and_debug_parameter_left_as_default_False(
         self):
     duration = Timelapsed.from_timestamp('sdfsdfsf4435435rete')
     self.assertEqual(duration, 'T/E')
Esempio n. 15
0
 def test_will_raise_an_ValuError_if_timestamp_is_out_of_range_with_safe_parameter_set_to_False(
         self):
     with self.assertRaises(ValueError):
         Timelapsed.from_timestamp(12345678934243324, safe=False)
Esempio n. 16
0
 def test_6_days_ago_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          6000 * 60 * 60 * 24,
                                          notation='lng')
     self.assertEqual(duration, '6 days ago')
Esempio n. 17
0
 def test_just_now_twitter_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='twitter')
     self.assertEqual(duration, 'n')
Esempio n. 18
0
 def test_1_week_ago_default_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60 * 60 * 24 * 7)
     self.assertEqual(duration, '1 week ago')
Esempio n. 19
0
 def test_just_now_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='lng')
     self.assertEqual(duration, 'just now')
Esempio n. 20
0
 def test_will_return_NA_if_timestamp_is_out_of_range_with_safe_parameter_left_as_default_True_and_debug_parameter_is_set_to_True(
         self):
     duration = Timelapsed.from_timestamp(324324234242424, debug=True)
     self.assertEqual(duration, 'N/A')
Esempio n. 21
0
 def test_1_minute_ago_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60,
                                          notation='mid')
     self.assertEqual(duration, '1min')
Esempio n. 22
0
 def test_1_week_ago_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          1000 * 60 * 60 * 24 * 7,
                                          notation='mid')
     self.assertEqual(duration, '1wk')
Esempio n. 23
0
 def test_17_minutes_ago_twitter_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          17000 * 60,
                                          notation='twitter')
     self.assertEqual(duration, '17m')
Esempio n. 24
0
 def test_3_weeks_ago_twitter_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          3000 * 60 * 60 * 24 * 7,
                                          notation='twitter')
     self.assertEqual(duration, '3w')
Esempio n. 25
0
 def test_42_minutes_ago_default_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          42000 * 60)
     self.assertEqual(duration, '42 minutes ago')
Esempio n. 26
0
 def test_23_minutes_ago_default_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp() -
                                          23000 * 60,
                                          notation='twitter')
     self.assertEqual(duration, '23m')