-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue-19-validate_date_invalid_weekday
- Loading branch information
Showing
3 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import unittest | ||
from datetime import date, datetime | ||
|
||
import cron_converter.sub_modules.utils as utils | ||
|
||
|
||
class UtilsTest(unittest.TestCase): | ||
|
||
def test_to_parts(self): | ||
today_d = date(day=20, month=5, year=2024) | ||
self.assertEqual(utils.to_parts(today_d), [None, None, 20, 5, 1], "The result has to be True") | ||
today_dt = datetime(minute=20, hour=23, day=20, month=5, year=2024) | ||
self.assertEqual(utils.to_parts(today_dt), [20, 23, 20, 5, 1], "The result has to be True") | ||
|
||
def test_iso_to_cron_weekday(self): | ||
iso_weekdays = range(1, 7+1, 1) | ||
cron_weekdays = [] | ||
for iso_weekday in iso_weekdays: | ||
cron_weekdays.append(utils.iso_to_cron_weekday(iso_weekday)) | ||
self.assertListEqual(cron_weekdays, [1, 2, 3, 4, 5, 6, 0], "The result has to be a range from 0 to 6") |