Exemplo 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)
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo n.º 6
0
 def test_just_now_mid_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='mid')
     self.assertEqual(duration, 'now')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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)
Exemplo 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')
Exemplo n.º 17
0
 def test_just_now_twitter_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='twitter')
     self.assertEqual(duration, 'n')
Exemplo 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')
Exemplo n.º 19
0
 def test_just_now_long_notation(self):
     duration = Timelapsed.from_timestamp(datetime.now().timestamp(),
                                          notation='lng')
     self.assertEqual(duration, 'just now')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')
Exemplo 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')