Skip to content
Snippets Groups Projects
Commit b0c7809c authored by Carlos Vega's avatar Carlos Vega
Browse files

added tests for utils

parent b846e242
No related branches found
No related tags found
1 merge request!171Feature/daily availability
Pipeline #6812 failed
import logging
from django.test import TestCase
from web.utils import get_weekdays_in_period
from datetime import date
import datetime
logger = logging.getLogger(__name__)
class Utils(TestCase):
def test_get_weekdays_in_period(self):
fromdate = date(2018,10,9)
todate = date(2018,10,12)
weekdays = get_weekdays_in_period(fromdate, todate)
self.assertEqual(weekdays, {2, 3, 4})
todate = datetime.datetime(2018, 10, 12, 00, 00, 00)
fromdate = datetime.datetime(2018, 10, 9, 00, 00, 00)
weekdays = get_weekdays_in_period(fromdate, todate)
self.assertEqual(weekdays, {2, 3, 4})
\ No newline at end of file
...@@ -33,9 +33,9 @@ def get_weekdays_in_period(fromdate, todate): ...@@ -33,9 +33,9 @@ def get_weekdays_in_period(fromdate, todate):
fromdate = datetime.datetime(2018, 10, 3, 15, 00, 00) fromdate = datetime.datetime(2018, 10, 3, 15, 00, 00)
todate = datetime.datetime.today() todate = datetime.datetime.today()
but they must have the same format ! but both dates must have the same format !
todate is not included in the range
Weekdays are returned as isoweekdays like the form described in week_choices from constants.py (starting at 1) Weekdays are returned as isoweekdays like the form described in week_choices from constants.py (starting at 1)
''' '''
if todate < fromdate: if todate < fromdate:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment