예제 #1
0
 def _get_choices(self):
     days = WeekDays('1111111')
     for day in days:
         yield day.index, day.get_name(context='stand-alone')
예제 #2
0
 def test_constructor_with_bit_string_of_invalid_length(self, bit_string):
     with pytest.raises(ValueError):
         WeekDays(bit_string)
예제 #3
0
 def test_constructor_with_bit_string_containing_invalid_characters(self):
     with pytest.raises(ValueError):
         WeekDays('foobarz')
예제 #4
0
 def test_str(self):
     i18n.get_locale = lambda: i18n.babel.Locale('fi')
     days = WeekDays('1000100')
     assert str(days) == 'maanantaina, perjantaina'
예제 #5
0
 def test_constructor_with_valid_bit_string(self):
     days = WeekDays('1000100')
     assert days._days == set([WeekDay(0), WeekDay(4)])
예제 #6
0
 def _coerce(self, value):
     if value is not None and not isinstance(value, WeekDays):
         return WeekDays(value)
     return value
예제 #7
0
 def test_unicode(self):
     i18n.get_locale = lambda: i18n.babel.Locale('fi')
     days = WeekDays('1000100')
     assert six.text_type(days) == u'maanantaina, perjantaina'
예제 #8
0
 def test_equality_with_unequal_bit_string(self):
     days = WeekDays('0001000')
     assert days != '0101000'
예제 #9
0
 def test_equality_with_unsupported_comparison(self):
     days = WeekDays('0001000')
     assert days != 0
예제 #10
0
 def test_as_bit_string(self, bit_string):
     days = WeekDays(bit_string)
     assert days.as_bit_string() == bit_string
예제 #11
0
 def test_equality_with_unequal_week_days_object(self):
     days = WeekDays('0001000')
     days2 = WeekDays('1000000')
     assert days != days2
예제 #12
0
 def test_representation(self):
     days = WeekDays('0000000')
     assert repr(days) == "WeekDays('0000000')"
예제 #13
0
 def test_constructor_with_another_week_days_object(self):
     days = WeekDays('0000000')
     another_days = WeekDays(days)
     assert days._days == another_days._days
예제 #14
0
 def test_as_bit_string(self, bit_string):
     days = WeekDays(bit_string)
     assert days.as_bit_string() == bit_string
예제 #15
0
 def process_data(self, value):
     self.data = WeekDays(value) if value else None
예제 #16
0
 def test_iterator_starts_from_locales_first_week_day(self):
     i18n.get_locale = lambda: flexmock(first_week_day=1)
     days = WeekDays('1111111')
     indices = list(day.index for day in days)
     assert indices == [1, 2, 3, 4, 5, 6, 0]
예제 #17
0
 def process_formdata(self, valuelist):
     self.data = WeekDays(self.coerce(x) for x in valuelist)
예제 #18
0
 def process_result_value(self, value, dialect):
     if value is not None:
         return WeekDays(value)