sqlalchemy_utils.Country

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

10 Examples 7

Example 1

Project: sqlalchemy-utils Source File: test_country.py
Function: test_constructor_with_wrong_type
    def test_constructor_with_wrong_type(self):
        with pytest.raises(TypeError) as e:
            Country(None)
        assert str(e.value) == (
            "Country() argument must be a string or a country, not 'NoneType'"
        )

Example 2

Project: sqlalchemy-utils Source File: test_country.py
Function: test_constructor_with_invalid_code
    def test_constructor_with_invalid_code(self):
        with pytest.raises(ValueError) as e:
            Country('SomeUnknownCode')
        assert str(e.value) == (
            'Could not convert string to country code: SomeUnknownCode'
        )

Example 3

Project: sqlalchemy-utils Source File: test_country.py
Function: test_parameter_processing
    def test_parameter_processing(self, session, User):
        user = User(
            country=Country(u'FI')
        )

        session.add(user)
        session.commit()

        user = session.query(User).first()
        assert user.country.name == u'Finland'

Example 4

Project: sqlalchemy-utils Source File: test_country.py
Function: test_init
    def test_init(self):
        assert Country(u'FI') == Country(Country(u'FI'))

Example 5

Project: sqlalchemy-utils Source File: test_country.py
Function: test_equality_operator
    def test_equality_operator(self):
        assert Country(u'FI') == u'FI'
        assert u'FI' == Country(u'FI')
        assert Country(u'FI') == Country(u'FI')

Example 6

Project: sqlalchemy-utils Source File: test_country.py
Function: test_non_equality_operator
    def test_non_equality_operator(self):
        assert Country(u'FI') != u'sv'
        assert not (Country(u'FI') != u'FI')

Example 7

Project: sqlalchemy-utils Source File: test_country.py
Function: test_hash
    def test_hash(self):
        return hash(Country('FI')) == hash('FI')

Example 8

Project: sqlalchemy-utils Source File: test_country.py
Function: test_repr
    def test_repr(self):
        return repr(Country('FI')) == "Country('FI')"

Example 9

Project: sqlalchemy-utils Source File: test_country.py
Function: test_unicode
    def test_unicode(self):
        country = Country('FI')
        assert six.text_type(country) == u'Finland'

Example 10

Project: sqlalchemy-utils Source File: test_country.py
Function: test_str
    def test_str(self):
        country = Country('FI')
        assert str(country) == 'Finland'