Esempio n. 1
0
 def test_extend_weekend_new_label(self):
     amds = {'17 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest', label='a')
     assert result == {
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 'a'
     }
Esempio n. 2
0
 def test_extend_weekend_sunday(self):
     amds = {'17 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest')
     assert result == {
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 5
     }
     result = extend_weekends(amds, how='previous')
     assert result == {
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('15 Dec 2017'): 5
     }
     result = extend_weekends(amds, how='next')
     assert result == {
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 5
     }
Esempio n. 3
0
 def test_extend_weekend_weekday_already_off2(self):
     amds = {'17 Dec 2017': 5, '15 Dec 2017': 5}
     result = extend_weekends(amds, how='previous')
     assert result == {
         get_timestamp('14 Dec 2017'): 5,
         get_timestamp('15 Dec 2017'): 5,
         get_timestamp('17 Dec 2017'): 5
     }
Esempio n. 4
0
 def test_extend_weekend_weekday_already_off1(self):
     amds = {'17 Dec 2017': 5, '18 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest')
     assert result == {
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 5,
         get_timestamp('19 Dec 2017'): 5
     }
Esempio n. 5
0
 def test_extend_weekend_strange_weekend(self):
     amds = {'16 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest', weekend=[5])
     # if there is a tie, 'nearest' == 'next'
     assert result == {
         get_timestamp('16 Dec 2017'): 5,
         get_timestamp('17 Dec 2017'): 5
     }
     result = extend_weekends(amds, how='next', weekend=[5, 6, 0])
     assert result == {
         get_timestamp('16 Dec 2017'): 5,
         get_timestamp('19 Dec 2017'): 5
     }
     result = extend_weekends(amds, how='previous', weekend=[3, 4, 5])
     assert result == {
         get_timestamp('13 Dec 2017'): 5,
         get_timestamp('16 Dec 2017'): 5
     }
     result = extend_weekends(amds, weekend=[])
     assert result == {get_timestamp('16 Dec 2017'): 5}
Esempio n. 6
0
 def test_extend_weekend_two_holidays_diff_labels(self):
     amds = {'16 Dec 2017': 3, '17 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest')
     assert result == {
         get_timestamp('15 Dec 2017'): 3,
         get_timestamp('16 Dec 2017'): 3,
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 5
     }
     result = extend_weekends(amds, how='previous')
     assert result == {
         get_timestamp('14 Dec 2017'): 5,
         get_timestamp('15 Dec 2017'): 3,
         get_timestamp('16 Dec 2017'): 3,
         get_timestamp('17 Dec 2017'): 5,
     }
     result = extend_weekends(amds, how='next')
     assert result == {
         get_timestamp('16 Dec 2017'): 3,
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 3,
         get_timestamp('19 Dec 2017'): 5
     }
Esempio n. 7
0
 def test_extend_weekend_two_holidays_new_label(self):
     amds = {'16 Dec 2017': 5, '17 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest', label=0)
     assert result == {
         get_timestamp('15 Dec 2017'): 0,
         get_timestamp('16 Dec 2017'): 5,
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 0
     }
     result = extend_weekends(amds, how='previous', label=0)
     assert result == {
         get_timestamp('14 Dec 2017'): 0,
         get_timestamp('15 Dec 2017'): 0,
         get_timestamp('16 Dec 2017'): 5,
         get_timestamp('17 Dec 2017'): 5,
     }
     result = extend_weekends(amds, how='next', label=0)
     assert result == {
         get_timestamp('16 Dec 2017'): 5,
         get_timestamp('17 Dec 2017'): 5,
         get_timestamp('18 Dec 2017'): 0,
         get_timestamp('19 Dec 2017'): 0
     }
Esempio n. 8
0
 def test_extend_weekend_weekday(self):
     amds = {'15 Dec 2017': 5}
     result = extend_weekends(amds, how='nearest')
     assert result == {get_timestamp('15 Dec 2017'): 5}