|
| 1 | +# These tests are auto-generated with test data from: |
| 2 | +# https://github.com/exercism/problem-specifications/tree/main/exercises/swift-scheduling/canonical-data.json |
| 3 | +# File last updated on 2025-03-03 |
| 4 | + |
| 5 | +import unittest |
| 6 | + |
| 7 | +from swift_scheduling import ( |
| 8 | + delivery_date, |
| 9 | +) |
| 10 | + |
| 11 | + |
| 12 | +class SwiftSchedulingTest(unittest.TestCase): |
| 13 | + def test_now_translates_to_two_hours_later(self): |
| 14 | + self.assertEqual( |
| 15 | + delivery_date("2012-02-13T09:00:00", "NOW"), "2012-02-13T11:00:00" |
| 16 | + ) |
| 17 | + |
| 18 | + def test_asap_before_one_in_the_afternoon_translates_to_today_at_five_in_the_afternoon( |
| 19 | + self, |
| 20 | + ): |
| 21 | + self.assertEqual( |
| 22 | + delivery_date("1999-06-03T09:45:00", "ASAP"), "1999-06-03T17:00:00" |
| 23 | + ) |
| 24 | + |
| 25 | + def test_asap_at_one_in_the_afternoon_translates_to_tomorrow_at_one_in_the_afternoon( |
| 26 | + self, |
| 27 | + ): |
| 28 | + self.assertEqual( |
| 29 | + delivery_date("2008-12-21T13:00:00", "ASAP"), "2008-12-22T13:00:00" |
| 30 | + ) |
| 31 | + |
| 32 | + def test_asap_after_one_in_the_afternoon_translates_to_tomorrow_at_one_in_the_afternoon( |
| 33 | + self, |
| 34 | + ): |
| 35 | + self.assertEqual( |
| 36 | + delivery_date("2008-12-21T14:50:00", "ASAP"), "2008-12-22T13:00:00" |
| 37 | + ) |
| 38 | + |
| 39 | + def test_eow_on_monday_translates_to_friday_at_five_in_the_afternoon(self): |
| 40 | + self.assertEqual( |
| 41 | + delivery_date("2025-02-03T16:00:00", "EOW"), "2025-02-07T17:00:00" |
| 42 | + ) |
| 43 | + |
| 44 | + def test_eow_on_tuesday_translates_to_friday_at_five_in_the_afternoon(self): |
| 45 | + self.assertEqual( |
| 46 | + delivery_date("1997-04-29T10:50:00", "EOW"), "1997-05-02T17:00:00" |
| 47 | + ) |
| 48 | + |
| 49 | + def test_eow_on_wednesday_translates_to_friday_at_five_in_the_afternoon(self): |
| 50 | + self.assertEqual( |
| 51 | + delivery_date("2005-09-14T11:00:00", "EOW"), "2005-09-16T17:00:00" |
| 52 | + ) |
| 53 | + |
| 54 | + def test_eow_on_thursday_translates_to_sunday_at_eight_in_the_evening(self): |
| 55 | + self.assertEqual( |
| 56 | + delivery_date("2011-05-19T08:30:00", "EOW"), "2011-05-22T20:00:00" |
| 57 | + ) |
| 58 | + |
| 59 | + def test_eow_on_friday_translates_to_sunday_at_eight_in_the_evening(self): |
| 60 | + self.assertEqual( |
| 61 | + delivery_date("2022-08-05T14:00:00", "EOW"), "2022-08-07T20:00:00" |
| 62 | + ) |
| 63 | + |
| 64 | + def test_eow_translates_to_leap_day(self): |
| 65 | + self.assertEqual( |
| 66 | + delivery_date("2008-02-25T10:30:00", "EOW"), "2008-02-29T17:00:00" |
| 67 | + ) |
| 68 | + |
| 69 | + def test_2_m_before_the_second_month_of_this_year_translates_to_the_first_workday_of_the_second_month_of_this_year( |
| 70 | + self, |
| 71 | + ): |
| 72 | + self.assertEqual( |
| 73 | + delivery_date("2007-01-02T14:15:00", "2M"), "2007-02-01T08:00:00" |
| 74 | + ) |
| 75 | + |
| 76 | + def test_11_m_in_the_eleventh_month_translates_to_the_first_workday_of_the_eleventh_month_of_next_year( |
| 77 | + self, |
| 78 | + ): |
| 79 | + self.assertEqual( |
| 80 | + delivery_date("2013-11-21T15:30:00", "11M"), "2014-11-03T08:00:00" |
| 81 | + ) |
| 82 | + |
| 83 | + def test_4_m_in_the_ninth_month_translates_to_the_first_workday_of_the_fourth_month_of_next_year( |
| 84 | + self, |
| 85 | + ): |
| 86 | + self.assertEqual( |
| 87 | + delivery_date("2019-11-18T15:15:00", "4M"), "2020-04-01T08:00:00" |
| 88 | + ) |
| 89 | + |
| 90 | + def test_q1_in_the_first_quarter_translates_to_the_last_workday_of_the_first_quarter_of_this_year( |
| 91 | + self, |
| 92 | + ): |
| 93 | + self.assertEqual( |
| 94 | + delivery_date("2003-01-01T10:45:00", "Q1"), "2003-03-31T08:00:00" |
| 95 | + ) |
| 96 | + |
| 97 | + def test_q4_in_the_second_quarter_translates_to_the_last_workday_of_the_fourth_quarter_of_this_year( |
| 98 | + self, |
| 99 | + ): |
| 100 | + self.assertEqual( |
| 101 | + delivery_date("2001-04-09T09:00:00", "Q4"), "2001-12-31T08:00:00" |
| 102 | + ) |
| 103 | + |
| 104 | + def test_q3_in_the_fourth_quarter_translates_to_the_last_workday_of_the_third_quarter_of_next_year( |
| 105 | + self, |
| 106 | + ): |
| 107 | + self.assertEqual( |
| 108 | + delivery_date("2022-10-06T11:00:00", "Q3"), "2023-09-29T08:00:00" |
| 109 | + ) |
0 commit comments