Пример #1
0
def test_get_user_111(mocked_get_connection):
    username = "******"
    res = get_user(username=username)
    res1 = get_user(username='******')

    # In this case res == res1, because return_value and other properties of
    # Mock object does not determines by fact params, but only by names (I guess)
    assert res == res1

    mocked_conn_get_user = mocked_get_connection.return_value.get_user
    expected_result = mocked_conn_get_user.return_value
    assert res is expected_result
    # mocked_conn_get_user.assert_called_once_with(username)
    mocked_conn_get_user.assert_has_calls(
        [mock.call(username), mock.call('username111')])
Пример #2
0
def test_get_user_222(mocked_get_connection, user, connection):
    mocked_get_connection.return_value = connection
    mocked_get_connection.return_value.get_user = user

    print(get_connection().engine.url)
    print(get_connection().get_user(username='******'))
    print(get_user(username='******'))
Пример #3
0
def test_get_user(mocked_get_connection):
    username = "******"
    res = get_user(username=username)
    mocked_conn_get_user = mocked_get_connection.return_value.get_user
    expected_res = mocked_conn_get_user.return_value
    assert res is expected_res
    mocked_conn_get_user.assert_called()
    mocked_conn_get_user.assert_called_once()
    mocked_conn_get_user.assert_called_once_with(username)
Пример #4
0
def test_get_user(mocked_get_conection, user):
    username = "******"
    mocked_conn_get_user = mocked_get_conection.return_value.get_user
    expected_result = user
    mocked_conn_get_user.return_value = expected_result
    res = get_user(username=username)
    assert res is expected_result
    # mocked_conn_get_user.assert_called()
    # mocked_conn_get_user.assert_called_once()
    mocked_conn_get_user.assert_called_once_with(username)