Beispiel #1
0
def test_get_single_user_without_essential_values():
    """Test error without password or email_address for get_user."""
    fixture_without_email = {
        "users": [{
            "password": "******",
            "name": "Test User 2"
        }]
    }

    with pytest.raises(KeyError) as exc_info:
        main.get_users(fixture_without_email)
    assert str(exc_info.value) == r"'username'"

    fixture_without_password = {
        "users": [{
            "username": "******",
            "name": "Test User 2"
        }]
    }

    with pytest.raises(KeyError) as exc_info:
        main.get_users(fixture_without_password)
    assert str(exc_info.value) == r"'password'"
Beispiel #2
0
def test_get_single_user_without_name():
    """Test correct user passed without name on EmailAuthUser."""
    fixture_without_name = {
        "users": [{
            "username": "******",
            "password": "******"
        }]
    }

    users = main.get_users(fixture_without_name)
    assert len(users) == 1
    assert isinstance(users[0], main.EmailAuthUser)
    assert users[0].email_address == "*****@*****.**"
    assert users[0].password == "password"
    assert users[0].name is None
Beispiel #3
0
def test_get_multiple_user_without_error():
    """Test for multiple user returned by get_user."""
    fixture_multiple_users = {
        "users": [
            {
                "username": "******",
                "password": "******"
            },
            {
                "username": "******",
                "password": "******"
            },
        ]
    }

    users = main.get_users(fixture_multiple_users)
    assert len(users) == 2
    assert isinstance(users[0],
                      main.EmailAuthUser), isinstance(users[1],
                                                      main.EmailAuthUser)
    assert users[0].email_address == "*****@*****.**", (
        users[1].email_address == "*****@*****.**")
    assert users[0].password == "password", users[1].password == "password2"
Beispiel #4
0
def test_get_empty_user():
    """Test get_user returns nothing when empty value is passed."""
    assert main.get_users({"users": []}) == []
Beispiel #5
0
def test_get_users_empty_config_raise_error():
    """Test empty data passed returns error."""
    with pytest.raises(KeyError) as exc_info:
        main.get_users({})

    assert str(exc_info.value) == "\"Missing 'users' config inside 'client'\""