sqlalchemy_utils.primitives.WeekDay

Here are the examples of the python api sqlalchemy_utils.primitives.WeekDay taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

30 Examples 7

Example 1

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    @pytest.mark.parametrize(
        ('index', 'first_week_day', 'position'),
        [
            (0, 0, 0),
            (1, 0, 1),
            (6, 0, 6),
            (0, 6, 1),
            (1, 6, 2),
            (6, 6, 0),
        ]
    )
    def test_position(self, index, first_week_day, position):
        i18n.get_locale = flexmock(first_week_day=first_week_day)
        day = WeekDay(index)
        assert day.position == position

Example 2

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    @pytest.mark.parametrize(
        ('index', 'first_week_day', 'position'),
        [
            (0, 0, 0),
            (1, 0, 1),
            (6, 0, 6),
            (0, 6, 1),
            (1, 6, 2),
            (6, 6, 0),
        ]
    )
    def test_position(self, index, first_week_day, position):
        i18n.get_locale = flexmock(first_week_day=first_week_day)
        day = WeekDay(index)
        assert day.position == position

Example 3

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_constructor_with_valid_index(self):
        day = WeekDay(1)
        assert day.index == 1

Example 4

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    @pytest.mark.parametrize('index', [-1, 7])
    def test_constructor_with_invalid_index(self, index):
        with pytest.raises(ValueError):
            WeekDay(index)

Example 5

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_equal_week_day(self):
        day = WeekDay(1)
        day2 = WeekDay(1)
        assert day == day2

Example 6

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_unequal_week_day(self):
        day = WeekDay(1)
        day2 = WeekDay(2)
        assert day != day2

Example 7

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_unsupported_comparison(self):
        day = WeekDay(1)
        assert day != 'foobar'

Example 8

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_hash_is_equal_to_index_hash(self):
        day = WeekDay(1)
        assert hash(day) == hash(day.index)

Example 9

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_representation(self):
        day = WeekDay(1)
        assert repr(day) == "WeekDay(1)"

Example 10

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_get_name_returns_localized_week_day_name(self):
        day = WeekDay(0)
        assert day.get_name() == u'maanantaina'

Example 11

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_override_get_locale_as_class_method(self):
        day = WeekDay(0)
        assert day.get_name() == u'maanantaina'

Example 12

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_name_delegates_to_get_name(self):
        day = WeekDay(0)
        flexmock(day).should_receive('get_name').and_return(u'maanantaina')
        assert day.name == u'maanantaina'

Example 13

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_unicode(self):
        day = WeekDay(0)
        flexmock(day).should_receive('name').and_return(u'maanantaina')
        assert six.text_type(day) == u'maanantaina'

Example 14

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_str(self):
        day = WeekDay(0)
        flexmock(day).should_receive('name').and_return(u'maanantaina')
        assert str(day) == 'maanantaina'

Example 15

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_constructor_with_valid_bit_string(self):
        days = WeekDays('1000100')
        assert days._days == set([WeekDay(0), WeekDay(4)])

Example 16

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_constructor_with_valid_index(self):
        day = WeekDay(1)
        assert day.index == 1

Example 17

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    @pytest.mark.parametrize('index', [-1, 7])
    def test_constructor_with_invalid_index(self, index):
        with pytest.raises(ValueError):
            WeekDay(index)

Example 18

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_equal_week_day(self):
        day = WeekDay(1)
        day2 = WeekDay(1)
        assert day == day2

Example 19

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_unequal_week_day(self):
        day = WeekDay(1)
        day2 = WeekDay(2)
        assert day != day2

Example 20

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_equality_with_unsupported_comparison(self):
        day = WeekDay(1)
        assert day != 'foobar'

Example 21

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_hash_is_equal_to_index_hash(self):
        day = WeekDay(1)
        assert hash(day) == hash(day.index)

Example 22

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_representation(self):
        day = WeekDay(1)
        assert repr(day) == "WeekDay(1)"

Example 23

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_get_name_returns_localized_week_day_name(self):
        day = WeekDay(0)
        assert day.get_name() == u'maanantaina'

Example 24

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_override_get_locale_as_class_method(self):
        day = WeekDay(0)
        assert day.get_name() == u'maanantaina'

Example 25

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_name_delegates_to_get_name(self):
        day = WeekDay(0)
        flexmock(day).should_receive('get_name').and_return(u'maanantaina')
        assert day.name == u'maanantaina'

Example 26

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_unicode(self):
        day = WeekDay(0)
        flexmock(day).should_receive('name').and_return(u'maanantaina')
        assert six.text_type(day) == u'maanantaina'

Example 27

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_str(self):
        day = WeekDay(0)
        flexmock(day).should_receive('name').and_return(u'maanantaina')
        assert str(day) == 'maanantaina'

Example 28

Project: sqlalchemy-utils
Source File: test_weekdays.py
View license
    def test_constructor_with_valid_bit_string(self):
        days = WeekDays('1000100')
        assert days._days == set([WeekDay(0), WeekDay(4)])

Example 29

Project: wtforms-alchemy
Source File: fields.py
View license
    def __init__(self, *args, **kwargs):
        kwargs['coerce'] = lambda x: WeekDay(int(x))
        super(WeekDaysField, self).__init__(*args, **kwargs)
        self.choices = self._get_choices

Example 30

Project: wtforms-alchemy
Source File: fields.py
View license
    def __init__(self, *args, **kwargs):
        kwargs['coerce'] = lambda x: WeekDay(int(x))
        super(WeekDaysField, self).__init__(*args, **kwargs)
        self.choices = self._get_choices