Skip to content

Commit

Permalink
Added new leapyear test case and regenerated test cases and tests toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
BethanyG committed Mar 3, 2025
1 parent 849db54 commit 1c39ffd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions exercises/practice/swift-scheduling/.meta/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def delivery_date(start, description):
due_date = start_date.replace(hour=17, minute=0)
else:
due_date = (
start_date.replace(hour=12, minute=0) +
start_date.replace(hour=13, minute=0) +
timedelta(days=1)
)
case 'EOW':
Expand Down Expand Up @@ -54,4 +54,4 @@ def delivery_date(start, description):
if due_date.isoweekday() == 7:
due_date -= timedelta(days=2)

return due_date.isoformat()
return due_date.isoformat()
3 changes: 3 additions & 0 deletions exercises/practice/swift-scheduling/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ description = "EOW on Thursday translates to Sunday at eight in the evening"
[bbffccf7-97f7-4244-888d-bdd64348fa2e]
description = "EOW on Friday translates to Sunday at eight in the evening"

[d651fcf4-290e-407c-8107-36b9076f39b2]
description = "EOW translates to leap day"

[439bf09f-3a0e-44e7-bad5-b7b6d0c4505a]
description = "2M before the second month of this year translates to the first workday of the second month of this year"

Expand Down
26 changes: 21 additions & 5 deletions exercises/practice/swift-scheduling/swift_scheduling_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These tests are auto-generated with test data from:
# https://github.com/exercism/problem-specifications/tree/main/exercises/swift-scheduling/canonical-data.json
# File last updated on 2025-03-02
# File last updated on 2025-03-03

import unittest

Expand All @@ -15,14 +15,25 @@ def test_now_translates_to_two_hours_later(self):
delivery_date("2012-02-13T09:00:00", "NOW"), "2012-02-13T11:00:00"
)

def test_asap_before_noon_translates_to_today_at_five_in_the_afternoon(self):
def test_asap_before_one_in_the_afternoon_translates_to_today_at_five_in_the_afternoon(
self,
):
self.assertEqual(
delivery_date("1999-06-03T09:45:00", "ASAP"), "1999-06-03T17:00:00"
)

def test_asap_after_noon_translates_to_tomorrow_at_noon(self):
def test_asap_at_one_in_the_afternoon_translates_to_tomorrow_at_one_in_the_afternoon(
self,
):
self.assertEqual(
delivery_date("2008-12-21T13:00:00", "ASAP"), "2008-12-22T13:00:00"
)

def test_asap_after_one_in_the_afternoon_translates_to_tomorrow_at_one_in_the_afternoon(
self,
):
self.assertEqual(
delivery_date("2008-12-21T13:30:00", "ASAP"), "2008-12-22T12:00:00"
delivery_date("2008-12-21T14:50:00", "ASAP"), "2008-12-22T13:00:00"
)

def test_eow_on_monday_translates_to_friday_at_five_in_the_afternoon(self):
Expand All @@ -47,7 +58,12 @@ def test_eow_on_thursday_translates_to_sunday_at_eight_in_the_evening(self):

def test_eow_on_friday_translates_to_sunday_at_eight_in_the_evening(self):
self.assertEqual(
delivery_date("2022-08-05T12:00:00", "EOW"), "2022-08-07T20:00:00"
delivery_date("2022-08-05T14:00:00", "EOW"), "2022-08-07T20:00:00"
)

def test_eow_translates_to_leap_day(self):
self.assertEqual(
delivery_date("2008-02-25T10:30:00", "EOW"), "2008-02-29T17:00:00"
)

def test_2_m_before_the_second_month_of_this_year_translates_to_the_first_workday_of_the_second_month_of_this_year(
Expand Down

0 comments on commit 1c39ffd

Please sign in to comment.