def test_throws_exception_when_generating_token_without_username():
    user = User()
    user.id = 1
    with pytest.raises(Exception):
        token = user.generate_auth_token()
def test_generates_valid_token():
    user = User()
    user.id = 1
    user.username = "******"
    assert user.generate_auth_token()
def test_throws_exception_when_generating_token_without_id():
    user = User()
    user.username = "******"
    with pytest.raises(Exception):
        token = user.generate_auth_token()