Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests in examples/miniapps/fastapi #622

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

polosaty
Copy link

@polosaty polosaty commented Sep 9, 2022

I tried to download the examples/miniapps/fastapi.
After installing the dependencies, I ran the tests:
py.test giphynavigator/tests.py --cov=giphynavigator

And got errors:

py.test giphynavigator/tests.py --cov=giphynavigator
============================================================================================================================= test session starts ==============================================================================================================================
platform linux -- Python 3.10.7, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/mg/ws/lang_exp/python/python-dependency-injector
plugins: anyio-3.6.1, cov-3.0.0, asyncio-0.19.0
asyncio: mode=strict
collected 3 items                                                                                                                                                                                                                                                              

giphynavigator/tests.py FFF                                                                                                                                                                                                                                              [100%]

=================================================================================================================================== FAILURES ===================================================================================================================================
__________________________________________________________________________________________________________________________________ test_index __________________________________________________________________________________________________________________________________

client = <async_generator object client at 0x7fbe5e2c36c0>

    @pytest.mark.asyncio
    async def test_index(client):
        giphy_client_mock = mock.AsyncMock(spec=GiphyClient)
        giphy_client_mock.search.return_value = {
            "data": [
                {"url": "https://giphy.com/gif1.gif"},
                {"url": "https://giphy.com/gif2.gif"},
            ],
        }
    
        with app.container.giphy_client.override(giphy_client_mock):
>           response = await client.get(
                "/",
                params={
                    "query": "test",
                    "limit": 10,
                },
            )
E           AttributeError: 'async_generator' object has no attribute 'get'

giphynavigator/tests.py:31: AttributeError
....
=========================================================================================================================== short test summary info ============================================================================================================================
FAILED giphynavigator/tests.py::test_index - AttributeError: 'async_generator' object has no attribute 'get'
FAILED giphynavigator/tests.py::test_index_no_data - AttributeError: 'async_generator' object has no attribute 'get'
FAILED giphynavigator/tests.py::test_index_default_params - AttributeError: 'async_generator' object has no attribute 'get'
============================================================================================================================== 3 failed in 0.55s ===============================================================================================================================

So here's a fix for this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant