3
3
4
4
from openinghours .models import OpeningHours , ClosingRules
5
5
from openinghours .templatetags .openinghours_tags import iso_day_to_weekday , is_open , next_time_open , \
6
- has_closing_rule_for_now , get_closing_rule_for_now
6
+ has_closing_rule_for_now , get_closing_rule_for_now , opening_hours
7
7
from openinghours .tests .tests import OpeningHoursTestCase
8
8
9
9
@@ -57,13 +57,13 @@ def test_next_time_open(self):
57
57
self .assertFalse (next_time_open (self .company ))
58
58
59
59
def test_has_closing_rule_for_now (self ):
60
- with freeze_time ("2015-12-26 10:00:00" ):
60
+ with freeze_time ("2015-12-26 10:00:00" ): # Holiday
61
61
self .assertTrue (has_closing_rule_for_now (self .company ))
62
62
with freeze_time ("2016-02-22 10:00:00" ):
63
63
self .assertFalse (has_closing_rule_for_now (self .company ))
64
64
65
65
def test_get_closing_rule_for_now (self ):
66
- with freeze_time ("2015-12-26 10:00:00" ):
66
+ with freeze_time ("2015-12-26 10:00:00" ): # Holiday
67
67
self .assertEqual (
68
68
get_closing_rule_for_now (self .company ).first (),
69
69
ClosingRules .objects .filter (company = self .company ).first ()
@@ -72,5 +72,19 @@ def test_get_closing_rule_for_now(self):
72
72
self .assertFalse (get_closing_rule_for_now (self .company ))
73
73
74
74
def opening_hours (self ):
75
- pass # TODO: Write test
76
-
75
+ with freeze_time ("2016-02-22 08:00:00" ): # Monday
76
+ opening_hours_str = opening_hours (self .company )
77
+ self .assertIn (u'Monday:' , opening_hours_str )
78
+ self .assertIn (u'Tuesday:' , opening_hours_str )
79
+ self .assertIn (u'Wednesday:' , opening_hours_str )
80
+ self .assertIn (u'Thursday:' , opening_hours_str )
81
+ self .assertIn (u'Friday:' , opening_hours_str )
82
+ self .assertIn (u'Saturday:' , opening_hours_str )
83
+ self .assertIn (u'Sunday:' , opening_hours_str )
84
+ self .assertIn (u'8:30am to 12:00pm' , opening_hours_str )
85
+ self .assertIn (u'9:00am to 17:00pm' , opening_hours_str )
86
+ self .assertIn (u'10:00am to 13:00pm' , opening_hours_str )
87
+ self .assertIn (u'12:30am to 22:00pm' , opening_hours_str )
88
+ self .assertIn (u'12:30am to 18:00pm' , opening_hours_str )
89
+ self .assertIn (u'18:30am to 22:00pm' , opening_hours_str )
90
+ self .assertNotIn (u'2:30am to 4:00am' , opening_hours_str )
0 commit comments