Changed exercise to use ordinal names instead of abbreviations

This commit is contained in:
ErnieWhite
2022-04-12 15:44:38 -05:00
committed by BethanyG
parent 0c7bad8a57
commit 2a3dda0b82
4 changed files with 72 additions and 74 deletions

View File

@@ -6,7 +6,7 @@
"input": { "input": {
"year": 2015, "year": 2015,
"month": 3, "month": 3,
"week": "5th", "week": "fifth",
"dayofweek": "Monday" "dayofweek": "Monday"
}, },
"expected": "2015-03-30" "expected": "2015-03-30"
@@ -17,7 +17,7 @@
"input": { "input": {
"year": 2024, "year": 2024,
"month": 2, "month": 2,
"week": "5th", "week": "fifth",
"dayofweek": "Thursday" "dayofweek": "Thursday"
}, },
"expected": "2024-02-29" "expected": "2024-02-29"
@@ -28,7 +28,7 @@
"input": { "input": {
"year": 2020, "year": 2020,
"month": 2, "month": 2,
"week": "5th", "week": "fifth",
"dayofweek": "Saturday" "dayofweek": "Saturday"
}, },
"expected": "2020-02-29" "expected": "2020-02-29"
@@ -61,7 +61,7 @@
"input": { "input": {
"year": 2022, "year": 2022,
"month": 2, "month": 2,
"week": "5th", "week": "fifth",
"dayofweek": "Monday" "dayofweek": "Monday"
}, },
"expected": {"error": "That day does not exist."} "expected": {"error": "That day does not exist."}
@@ -72,7 +72,7 @@
"input": { "input": {
"year": 2022, "year": 2022,
"month": 8, "month": 8,
"week": "5th", "week": "fifth",
"dayofweek": "Friday" "dayofweek": "Friday"
}, },
"expected": {"error": "That day does not exist."} "expected": {"error": "That day does not exist."}
@@ -83,7 +83,7 @@
"input": { "input": {
"year": 2023, "year": 2023,
"month": 5, "month": 5,
"week": "5th", "week": "fifth",
"dayofweek": "Thursday" "dayofweek": "Thursday"
}, },
"expected": {"error": "That day does not exist."} "expected": {"error": "That day does not exist."}

View File

@@ -14,7 +14,8 @@ def _choice(week):
return lambda dates: next(date for date in dates if return lambda dates: next(date for date in dates if
13 <= date.day <= 19) 13 <= date.day <= 19)
day = -1 if (week == 'last') else (int(week[0]) - 1) ordinals = {'first', 'second', 'third', 'fourth', 'fifth', 'sixth'}
day = -1 if (week == 'last') else (ordinals.index(week))
def _func(dates): def _func(dates):
if day < len(dates): if day < len(dates):

View File

@@ -6,9 +6,6 @@
{%- set input.month = case["input"]["month"] %} {%- set input.month = case["input"]["month"] %}
{%- set input.week = case["input"]["week"] %} {%- set input.week = case["input"]["week"] %}
{%- set input.dayofweek = case["input"]["dayofweek"] %} {%- set input.dayofweek = case["input"]["dayofweek"] %}
{%- for (k, v) in {"first":"1st", "second":"2nd", "third":"3rd", "fourth":"4th", "fifth":"5th", "sixth":"6th"}.items() %}
{%- set input.week = input.week.replace(k, v) %}
{%- endfor %}
{%- if case is error_case %} {%- if case is error_case %}
with self.assertRaises(MeetupDayException) as err: with self.assertRaises(MeetupDayException) as err:
{{ case["property"] }}({{ input.year }}, {{ input.month }}, "{{ input.week }}", "{{ input.dayofweek }}") {{ case["property"] }}({{ input.year }}, {{ input.month }}, "{{ input.week }}", "{{ input.dayofweek }}")

View File

@@ -74,172 +74,172 @@ class MeetupTest(unittest.TestCase):
self.assertEqual(meetup(2013, 10, "teenth", "Sunday"), date(2013, 10, 13)) self.assertEqual(meetup(2013, 10, "teenth", "Sunday"), date(2013, 10, 13))
def test_when_first_monday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_monday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 3, "1st", "Monday"), date(2013, 3, 4)) self.assertEqual(meetup(2013, 3, "first", "Monday"), date(2013, 3, 4))
def test_when_first_monday_is_the_1st_the_first_day_of_the_first_week(self): def test_when_first_monday_is_the_1st_the_first_day_of_the_first_week(self):
self.assertEqual(meetup(2013, 4, "1st", "Monday"), date(2013, 4, 1)) self.assertEqual(meetup(2013, 4, "first", "Monday"), date(2013, 4, 1))
def test_when_first_tuesday_is_the_7th_the_last_day_of_the_first_week(self): def test_when_first_tuesday_is_the_7th_the_last_day_of_the_first_week(self):
self.assertEqual(meetup(2013, 5, "1st", "Tuesday"), date(2013, 5, 7)) self.assertEqual(meetup(2013, 5, "first", "Tuesday"), date(2013, 5, 7))
def test_when_first_tuesday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_tuesday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 6, "1st", "Tuesday"), date(2013, 6, 4)) self.assertEqual(meetup(2013, 6, "first", "Tuesday"), date(2013, 6, 4))
def test_when_first_wednesday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_wednesday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 7, "1st", "Wednesday"), date(2013, 7, 3)) self.assertEqual(meetup(2013, 7, "first", "Wednesday"), date(2013, 7, 3))
def test_when_first_wednesday_is_the_7th_the_last_day_of_the_first_week(self): def test_when_first_wednesday_is_the_7th_the_last_day_of_the_first_week(self):
self.assertEqual(meetup(2013, 8, "1st", "Wednesday"), date(2013, 8, 7)) self.assertEqual(meetup(2013, 8, "first", "Wednesday"), date(2013, 8, 7))
def test_when_first_thursday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_thursday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 9, "1st", "Thursday"), date(2013, 9, 5)) self.assertEqual(meetup(2013, 9, "first", "Thursday"), date(2013, 9, 5))
def test_when_first_thursday_is_another_day_in_the_middle_of_the_first_week(self): def test_when_first_thursday_is_another_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 10, "1st", "Thursday"), date(2013, 10, 3)) self.assertEqual(meetup(2013, 10, "first", "Thursday"), date(2013, 10, 3))
def test_when_first_friday_is_the_1st_the_first_day_of_the_first_week(self): def test_when_first_friday_is_the_1st_the_first_day_of_the_first_week(self):
self.assertEqual(meetup(2013, 11, "1st", "Friday"), date(2013, 11, 1)) self.assertEqual(meetup(2013, 11, "first", "Friday"), date(2013, 11, 1))
def test_when_first_friday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_friday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 12, "1st", "Friday"), date(2013, 12, 6)) self.assertEqual(meetup(2013, 12, "first", "Friday"), date(2013, 12, 6))
def test_when_first_saturday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_saturday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 1, "1st", "Saturday"), date(2013, 1, 5)) self.assertEqual(meetup(2013, 1, "first", "Saturday"), date(2013, 1, 5))
def test_when_first_saturday_is_another_day_in_the_middle_of_the_first_week(self): def test_when_first_saturday_is_another_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 2, "1st", "Saturday"), date(2013, 2, 2)) self.assertEqual(meetup(2013, 2, "first", "Saturday"), date(2013, 2, 2))
def test_when_first_sunday_is_some_day_in_the_middle_of_the_first_week(self): def test_when_first_sunday_is_some_day_in_the_middle_of_the_first_week(self):
self.assertEqual(meetup(2013, 3, "1st", "Sunday"), date(2013, 3, 3)) self.assertEqual(meetup(2013, 3, "first", "Sunday"), date(2013, 3, 3))
def test_when_first_sunday_is_the_7th_the_last_day_of_the_first_week(self): def test_when_first_sunday_is_the_7th_the_last_day_of_the_first_week(self):
self.assertEqual(meetup(2013, 4, "1st", "Sunday"), date(2013, 4, 7)) self.assertEqual(meetup(2013, 4, "first", "Sunday"), date(2013, 4, 7))
def test_when_second_monday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_monday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 3, "2nd", "Monday"), date(2013, 3, 11)) self.assertEqual(meetup(2013, 3, "second", "Monday"), date(2013, 3, 11))
def test_when_second_monday_is_the_8th_the_first_day_of_the_second_week(self): def test_when_second_monday_is_the_8th_the_first_day_of_the_second_week(self):
self.assertEqual(meetup(2013, 4, "2nd", "Monday"), date(2013, 4, 8)) self.assertEqual(meetup(2013, 4, "second", "Monday"), date(2013, 4, 8))
def test_when_second_tuesday_is_the_14th_the_last_day_of_the_second_week(self): def test_when_second_tuesday_is_the_14th_the_last_day_of_the_second_week(self):
self.assertEqual(meetup(2013, 5, "2nd", "Tuesday"), date(2013, 5, 14)) self.assertEqual(meetup(2013, 5, "second", "Tuesday"), date(2013, 5, 14))
def test_when_second_tuesday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_tuesday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 6, "2nd", "Tuesday"), date(2013, 6, 11)) self.assertEqual(meetup(2013, 6, "second", "Tuesday"), date(2013, 6, 11))
def test_when_second_wednesday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_wednesday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 7, "2nd", "Wednesday"), date(2013, 7, 10)) self.assertEqual(meetup(2013, 7, "second", "Wednesday"), date(2013, 7, 10))
def test_when_second_wednesday_is_the_14th_the_last_day_of_the_second_week(self): def test_when_second_wednesday_is_the_14th_the_last_day_of_the_second_week(self):
self.assertEqual(meetup(2013, 8, "2nd", "Wednesday"), date(2013, 8, 14)) self.assertEqual(meetup(2013, 8, "second", "Wednesday"), date(2013, 8, 14))
def test_when_second_thursday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_thursday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 9, "2nd", "Thursday"), date(2013, 9, 12)) self.assertEqual(meetup(2013, 9, "second", "Thursday"), date(2013, 9, 12))
def test_when_second_thursday_is_another_day_in_the_middle_of_the_second_week(self): def test_when_second_thursday_is_another_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 10, "2nd", "Thursday"), date(2013, 10, 10)) self.assertEqual(meetup(2013, 10, "second", "Thursday"), date(2013, 10, 10))
def test_when_second_friday_is_the_8th_the_first_day_of_the_second_week(self): def test_when_second_friday_is_the_8th_the_first_day_of_the_second_week(self):
self.assertEqual(meetup(2013, 11, "2nd", "Friday"), date(2013, 11, 8)) self.assertEqual(meetup(2013, 11, "second", "Friday"), date(2013, 11, 8))
def test_when_second_friday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_friday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 12, "2nd", "Friday"), date(2013, 12, 13)) self.assertEqual(meetup(2013, 12, "second", "Friday"), date(2013, 12, 13))
def test_when_second_saturday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_saturday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 1, "2nd", "Saturday"), date(2013, 1, 12)) self.assertEqual(meetup(2013, 1, "second", "Saturday"), date(2013, 1, 12))
def test_when_second_saturday_is_another_day_in_the_middle_of_the_second_week(self): def test_when_second_saturday_is_another_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 2, "2nd", "Saturday"), date(2013, 2, 9)) self.assertEqual(meetup(2013, 2, "second", "Saturday"), date(2013, 2, 9))
def test_when_second_sunday_is_some_day_in_the_middle_of_the_second_week(self): def test_when_second_sunday_is_some_day_in_the_middle_of_the_second_week(self):
self.assertEqual(meetup(2013, 3, "2nd", "Sunday"), date(2013, 3, 10)) self.assertEqual(meetup(2013, 3, "second", "Sunday"), date(2013, 3, 10))
def test_when_second_sunday_is_the_14th_the_last_day_of_the_second_week(self): def test_when_second_sunday_is_the_14th_the_last_day_of_the_second_week(self):
self.assertEqual(meetup(2013, 4, "2nd", "Sunday"), date(2013, 4, 14)) self.assertEqual(meetup(2013, 4, "second", "Sunday"), date(2013, 4, 14))
def test_when_third_monday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_monday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 3, "3rd", "Monday"), date(2013, 3, 18)) self.assertEqual(meetup(2013, 3, "third", "Monday"), date(2013, 3, 18))
def test_when_third_monday_is_the_15th_the_first_day_of_the_third_week(self): def test_when_third_monday_is_the_15th_the_first_day_of_the_third_week(self):
self.assertEqual(meetup(2013, 4, "3rd", "Monday"), date(2013, 4, 15)) self.assertEqual(meetup(2013, 4, "third", "Monday"), date(2013, 4, 15))
def test_when_third_tuesday_is_the_21st_the_last_day_of_the_third_week(self): def test_when_third_tuesday_is_the_21st_the_last_day_of_the_third_week(self):
self.assertEqual(meetup(2013, 5, "3rd", "Tuesday"), date(2013, 5, 21)) self.assertEqual(meetup(2013, 5, "third", "Tuesday"), date(2013, 5, 21))
def test_when_third_tuesday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_tuesday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 6, "3rd", "Tuesday"), date(2013, 6, 18)) self.assertEqual(meetup(2013, 6, "third", "Tuesday"), date(2013, 6, 18))
def test_when_third_wednesday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_wednesday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 7, "3rd", "Wednesday"), date(2013, 7, 17)) self.assertEqual(meetup(2013, 7, "third", "Wednesday"), date(2013, 7, 17))
def test_when_third_wednesday_is_the_21st_the_last_day_of_the_third_week(self): def test_when_third_wednesday_is_the_21st_the_last_day_of_the_third_week(self):
self.assertEqual(meetup(2013, 8, "3rd", "Wednesday"), date(2013, 8, 21)) self.assertEqual(meetup(2013, 8, "third", "Wednesday"), date(2013, 8, 21))
def test_when_third_thursday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_thursday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 9, "3rd", "Thursday"), date(2013, 9, 19)) self.assertEqual(meetup(2013, 9, "third", "Thursday"), date(2013, 9, 19))
def test_when_third_thursday_is_another_day_in_the_middle_of_the_third_week(self): def test_when_third_thursday_is_another_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 10, "3rd", "Thursday"), date(2013, 10, 17)) self.assertEqual(meetup(2013, 10, "third", "Thursday"), date(2013, 10, 17))
def test_when_third_friday_is_the_15th_the_first_day_of_the_third_week(self): def test_when_third_friday_is_the_15th_the_first_day_of_the_third_week(self):
self.assertEqual(meetup(2013, 11, "3rd", "Friday"), date(2013, 11, 15)) self.assertEqual(meetup(2013, 11, "third", "Friday"), date(2013, 11, 15))
def test_when_third_friday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_friday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 12, "3rd", "Friday"), date(2013, 12, 20)) self.assertEqual(meetup(2013, 12, "third", "Friday"), date(2013, 12, 20))
def test_when_third_saturday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_saturday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 1, "3rd", "Saturday"), date(2013, 1, 19)) self.assertEqual(meetup(2013, 1, "third", "Saturday"), date(2013, 1, 19))
def test_when_third_saturday_is_another_day_in_the_middle_of_the_third_week(self): def test_when_third_saturday_is_another_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 2, "3rd", "Saturday"), date(2013, 2, 16)) self.assertEqual(meetup(2013, 2, "third", "Saturday"), date(2013, 2, 16))
def test_when_third_sunday_is_some_day_in_the_middle_of_the_third_week(self): def test_when_third_sunday_is_some_day_in_the_middle_of_the_third_week(self):
self.assertEqual(meetup(2013, 3, "3rd", "Sunday"), date(2013, 3, 17)) self.assertEqual(meetup(2013, 3, "third", "Sunday"), date(2013, 3, 17))
def test_when_third_sunday_is_the_21st_the_last_day_of_the_third_week(self): def test_when_third_sunday_is_the_21st_the_last_day_of_the_third_week(self):
self.assertEqual(meetup(2013, 4, "3rd", "Sunday"), date(2013, 4, 21)) self.assertEqual(meetup(2013, 4, "third", "Sunday"), date(2013, 4, 21))
def test_when_fourth_monday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_monday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 3, "4th", "Monday"), date(2013, 3, 25)) self.assertEqual(meetup(2013, 3, "fourth", "Monday"), date(2013, 3, 25))
def test_when_fourth_monday_is_the_22nd_the_first_day_of_the_fourth_week(self): def test_when_fourth_monday_is_the_22nd_the_first_day_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 4, "4th", "Monday"), date(2013, 4, 22)) self.assertEqual(meetup(2013, 4, "fourth", "Monday"), date(2013, 4, 22))
def test_when_fourth_tuesday_is_the_28th_the_last_day_of_the_fourth_week(self): def test_when_fourth_tuesday_is_the_28th_the_last_day_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 5, "4th", "Tuesday"), date(2013, 5, 28)) self.assertEqual(meetup(2013, 5, "fourth", "Tuesday"), date(2013, 5, 28))
def test_when_fourth_tuesday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_tuesday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 6, "4th", "Tuesday"), date(2013, 6, 25)) self.assertEqual(meetup(2013, 6, "fourth", "Tuesday"), date(2013, 6, 25))
def test_when_fourth_wednesday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_wednesday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 7, "4th", "Wednesday"), date(2013, 7, 24)) self.assertEqual(meetup(2013, 7, "fourth", "Wednesday"), date(2013, 7, 24))
def test_when_fourth_wednesday_is_the_28th_the_last_day_of_the_fourth_week(self): def test_when_fourth_wednesday_is_the_28th_the_last_day_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 8, "4th", "Wednesday"), date(2013, 8, 28)) self.assertEqual(meetup(2013, 8, "fourth", "Wednesday"), date(2013, 8, 28))
def test_when_fourth_thursday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_thursday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 9, "4th", "Thursday"), date(2013, 9, 26)) self.assertEqual(meetup(2013, 9, "fourth", "Thursday"), date(2013, 9, 26))
def test_when_fourth_thursday_is_another_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_thursday_is_another_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 10, "4th", "Thursday"), date(2013, 10, 24)) self.assertEqual(meetup(2013, 10, "fourth", "Thursday"), date(2013, 10, 24))
def test_when_fourth_friday_is_the_22nd_the_first_day_of_the_fourth_week(self): def test_when_fourth_friday_is_the_22nd_the_first_day_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 11, "4th", "Friday"), date(2013, 11, 22)) self.assertEqual(meetup(2013, 11, "fourth", "Friday"), date(2013, 11, 22))
def test_when_fourth_friday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_friday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 12, "4th", "Friday"), date(2013, 12, 27)) self.assertEqual(meetup(2013, 12, "fourth", "Friday"), date(2013, 12, 27))
def test_when_fourth_saturday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_saturday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 1, "4th", "Saturday"), date(2013, 1, 26)) self.assertEqual(meetup(2013, 1, "fourth", "Saturday"), date(2013, 1, 26))
def test_when_fourth_saturday_is_another_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_saturday_is_another_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 2, "4th", "Saturday"), date(2013, 2, 23)) self.assertEqual(meetup(2013, 2, "fourth", "Saturday"), date(2013, 2, 23))
def test_when_fourth_sunday_is_some_day_in_the_middle_of_the_fourth_week(self): def test_when_fourth_sunday_is_some_day_in_the_middle_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 3, "4th", "Sunday"), date(2013, 3, 24)) self.assertEqual(meetup(2013, 3, "fourth", "Sunday"), date(2013, 3, 24))
def test_when_fourth_sunday_is_the_28th_the_last_day_of_the_fourth_week(self): def test_when_fourth_sunday_is_the_28th_the_last_day_of_the_fourth_week(self):
self.assertEqual(meetup(2013, 4, "4th", "Sunday"), date(2013, 4, 28)) self.assertEqual(meetup(2013, 4, "fourth", "Sunday"), date(2013, 4, 28))
def test_last_monday_in_a_month_with_four_mondays(self): def test_last_monday_in_a_month_with_four_mondays(self):
self.assertEqual(meetup(2013, 3, "last", "Monday"), date(2013, 3, 25)) self.assertEqual(meetup(2013, 3, "last", "Monday"), date(2013, 3, 25))
@@ -293,18 +293,18 @@ class MeetupTest(unittest.TestCase):
self.assertEqual(meetup(2015, 2, "last", "Sunday"), date(2015, 2, 22)) self.assertEqual(meetup(2015, 2, "last", "Sunday"), date(2015, 2, 22))
def test_when_first_friday_is_the_7th_the_last_day_of_the_first_week(self): def test_when_first_friday_is_the_7th_the_last_day_of_the_first_week(self):
self.assertEqual(meetup(2012, 12, "1st", "Friday"), date(2012, 12, 7)) self.assertEqual(meetup(2012, 12, "first", "Friday"), date(2012, 12, 7))
# Additional tests for this track # Additional tests for this track
def test_fifth_monday_of_march_2015(self): def test_fifth_monday_of_march_2015(self):
self.assertEqual(meetup(2015, 3, "5th", "Monday"), date(2015, 3, 30)) self.assertEqual(meetup(2015, 3, "fifth", "Monday"), date(2015, 3, 30))
def test_fifth_thursday_of_february_2024(self): def test_fifth_thursday_of_february_2024(self):
self.assertEqual(meetup(2024, 2, "5th", "Thursday"), date(2024, 2, 29)) self.assertEqual(meetup(2024, 2, "fifth", "Thursday"), date(2024, 2, 29))
def test_fifth_saturday_of_february_2020(self): def test_fifth_saturday_of_february_2020(self):
self.assertEqual(meetup(2020, 2, "5th", "Saturday"), date(2020, 2, 29)) self.assertEqual(meetup(2020, 2, "fifth", "Saturday"), date(2020, 2, 29))
def test_last_sunday_of_june_2024(self): def test_last_sunday_of_june_2024(self):
self.assertEqual(meetup(2024, 6, "last", "Sunday"), date(2024, 6, 30)) self.assertEqual(meetup(2024, 6, "last", "Sunday"), date(2024, 6, 30))
@@ -314,18 +314,18 @@ class MeetupTest(unittest.TestCase):
def test_nonexistent_fifth_monday_of_february_2022(self): def test_nonexistent_fifth_monday_of_february_2022(self):
with self.assertRaises(MeetupDayException) as err: with self.assertRaises(MeetupDayException) as err:
meetup(2022, 2, "5th", "Monday") meetup(2022, 2, "fifth", "Monday")
self.assertEqual(type(err.exception), MeetupDayException) self.assertEqual(type(err.exception), MeetupDayException)
self.assertEqual(err.exception.args[0], "That day does not exist.") self.assertEqual(err.exception.args[0], "That day does not exist.")
def test_nonexistent_fifth_friday_of_august_2022(self): def test_nonexistent_fifth_friday_of_august_2022(self):
with self.assertRaises(MeetupDayException) as err: with self.assertRaises(MeetupDayException) as err:
meetup(2022, 8, "5th", "Friday") meetup(2022, 8, "fifth", "Friday")
self.assertEqual(type(err.exception), MeetupDayException) self.assertEqual(type(err.exception), MeetupDayException)
self.assertEqual(err.exception.args[0], "That day does not exist.") self.assertEqual(err.exception.args[0], "That day does not exist.")
def test_nonexistent_fifth_thursday_of_may_2023(self): def test_nonexistent_fifth_thursday_of_may_2023(self):
with self.assertRaises(MeetupDayException) as err: with self.assertRaises(MeetupDayException) as err:
meetup(2023, 5, "5th", "Thursday") meetup(2023, 5, "fifth", "Thursday")
self.assertEqual(type(err.exception), MeetupDayException) self.assertEqual(type(err.exception), MeetupDayException)
self.assertEqual(err.exception.args[0], "That day does not exist.") self.assertEqual(err.exception.args[0], "That day does not exist.")