'django graphene pytest mock query not working

I have a simple test case like:

@patch('helpers.queries.Query.resolve_profile_lookup')
def test_profile_lookup(mock_resolve_profile_lookup, client, client_query):

    mock_resolve_profile_lookup.return_value = [
        {"name": "First name"},
        {"address": "First address"},
    ]
    response = client_query(
        """
        query profileLookup($search: String!){
            profileLookup(search: $search) {
                name
                address
            }
        }
        """,
        variables={"search": "jack"},
    )
    content = json.loads(response.content)
    assert mock_resolve_profile_lookup.called

Here, I want to mock the resolve_profile_lookup query that I have in Query.

From my understanding the function I patch is mocked while running test case, but its not working here.

Anything that I am missing here ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source