Conversation
tests/test_autopost.py
Outdated
| mocker: MockerFixture, autopost: AutoPoster | ||
| ) -> None: | ||
| error_callback = mock.Mock() | ||
| side_effect = HTTPException("Internal Server Error", 500) |
There was a problem hiding this comment.
why are we testing 500s? and if we do, could we please not send them to the actual API, it pollutes my observability. mock an error instead.
There was a problem hiding this comment.
This has been here in upstream. To my knowledge, the tests do not send anything to the actual API. (note the mock API tokens.)
There was a problem hiding this comment.
Would be good to verify, the api token is mocked, not the client
There was a problem hiding this comment.
See the MOCK_TOKEN = ".eyJfdCI6IiIsImlkIjoiMzY0ODA2MDI5ODc2NTU1Nzc2In0=." constant in the test files. The client objects are created from this mock token:
# test_autoposter.py
@pytest.fixture
def autopost(session: ClientSession) -> AutoPoster:
return AutoPoster(DBLClient(MOCK_TOKEN, session=session))
# test_client.py
@pytest.fixture
def client(session: ClientSession) -> topgg.DBLClient:
return topgg.DBLClient(MOCK_TOKEN, session=session)There was a problem hiding this comment.
ClientSession was the thing to point out I suppose, I don't know enough about how the http module works in python, but it makes sense that if that's mocked it should be fine.
There was a problem hiding this comment.
ClientSession is an aiohttp object that lets you send HTTP requests via session.get, session.post, etc.
The following pull request is a toned down version of #87. This pull request updates the
pytesttests alongside #87. It has been successfully tested when paired with it.