Changeset 24596da in OpenWorkouts-current for ow/tests/models/test_root.py


Ignore:
Timestamp:
Feb 27, 2019, 6:28:07 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
cef474f
Parents:
68d00f5
Message:

Added missing tests, raised overall coverage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/tests/models/test_root.py

    r68d00f5 r24596da  
    112112            user = root.get_user_by_email(Mock())
    113113
     114    def test_get_user_by_nickname(self, root, john):
     115        # set a nickname for john
     116        john.nickname = 'JohnDoe'
     117        root.reindex(john)
     118        user = root.get_user_by_nickname('JohnDoe')
     119        assert user == john
     120        user = root.get_user_by_nickname('NonExistant')
     121        assert user is None
     122        # passing in None
     123        user = root.get_user_by_nickname(None)
     124        assert user is None
     125        # passing in something that is not None or a string will break
     126        # the query code
     127        with pytest.raises(TypeError):
     128            user = root.get_user_by_nickname(False)
     129        with pytest.raises(TypeError):
     130            user = root.get_user_by_nickname(Mock())
     131
    114132    def test_users(self, root, john):
    115133        assert root.users == [john]
Note: See TracChangeset for help on using the changeset viewer.