@@ -108,12 +108,47 @@ def test_weekdaypstr_invalid():
108108 weekdaypstr ('foobar' )
109109
110110
111- def test_construct_daynames ():
112- with freeze_time ('2016-9-19' ):
113- assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Today'
114- assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Tomorrow'
115- assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Wednesday'
116-
111+ class TestConstructDayNames :
112+ def test_construct_daynames (self ):
113+ with freeze_time ('2016-9-19' ):
114+ assert construct_daynames (dt .date (2016 , 9 , 18 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Sunday'
115+ assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Today'
116+ assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Tomorrow'
117+ assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Wednesday'
118+
119+ # freeztime freezes to UTC but construct_daynames should give as back the
120+ # daynames relative the the user's local timezone
121+ def test_construct_daynames_with_datetime (self ):
122+ with freeze_time ('2016-9-19 22:53' ):
123+ assert construct_daynames (dt .date (2016 , 9 , 18 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Sunday'
124+ assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Monday'
125+ assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Today'
126+ assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Tomorrow'
127+ assert construct_daynames (dt .date (2016 , 9 , 22 ), local_timezone = LOCALE_BERLIN ['local_timezone' ]) == 'Thursday'
128+
129+ def test_construct_daynames_los_angeles (self ):
130+ with freeze_time ('2016-9-19 22:53' ):
131+ assert construct_daynames (dt .date (2016 , 9 , 18 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Sunday'
132+ assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Today'
133+ assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Tomorrow'
134+ assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Wednesday'
135+ assert construct_daynames (dt .date (2016 , 9 , 22 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Thursday'
136+
137+ def test_construct_daynames_los_angeles_morning (self ):
138+ with freeze_time ('2016-9-19 06:30' ):
139+ assert construct_daynames (dt .date (2016 , 9 , 18 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Today'
140+ assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Tomorrow'
141+ assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Tuesday'
142+ assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Wednesday'
143+ assert construct_daynames (dt .date (2016 , 9 , 22 ), local_timezone = pytz .timezone ('America/Los_Angeles' )) == 'Thursday'
144+
145+ def test_construct_daynames_auckland (self ):
146+ with freeze_time ('2016-9-19 22:53' ):
147+ assert construct_daynames (dt .date (2016 , 9 , 18 ), local_timezone = pytz .timezone ('Pacific/Auckland' )) == 'Sunday'
148+ assert construct_daynames (dt .date (2016 , 9 , 19 ), local_timezone = pytz .timezone ('Pacific/Auckland' )) == 'Monday'
149+ assert construct_daynames (dt .date (2016 , 9 , 20 ), local_timezone = pytz .timezone ('Pacific/Auckland' )) == 'Today'
150+ assert construct_daynames (dt .date (2016 , 9 , 21 ), local_timezone = pytz .timezone ('Pacific/Auckland' )) == 'Tomorrow'
151+ assert construct_daynames (dt .date (2016 , 9 , 22 ), local_timezone = pytz .timezone ('Pacific/Auckland' )) == 'Thursday'
117152
118153class TestGuessDatetimefstr :
119154
0 commit comments