fix: async middleware is equivalent to sync middleware - DIA-61984#107
fix: async middleware is equivalent to sync middleware - DIA-61984#107arththebird merged 7 commits intomasterfrom
Conversation
| # reload fastapi_sqla to clear sqla deferred reflection mapping stored in Base | ||
| importlib.reload(fastapi_sqla.models) | ||
| importlib.reload(fastapi_sqla.sqla) | ||
| importlib.reload(fastapi_sqla.async_sqla) |
There was a problem hiding this comment.
Forgotten in previous refactor
| @@ -0,0 +1,83 @@ | |||
| from unittest.mock import Mock | |||
There was a problem hiding this comment.
The middleware tests were refactored to improve coverage for the async version by adopting a similar pattern as the pagination tests.
| @@ -1,191 +0,0 @@ | |||
| from unittest.mock import Mock, patch | |||
There was a problem hiding this comment.
The tests related to startup were moved to test_startup and the ones related to open_session moved to test_open_session.
|
|
||
|
|
||
| @fixture(params=[True, False]) | ||
| def case_sensitive_environ(environ, request): |
There was a problem hiding this comment.
It was causing issue with the PYTEST_CURRENT_TEST env var, so moved to its own test
| from fastapi_sqla.sqla import _Session | ||
|
|
||
| if "dont_patch_engines" in request.keywords: | ||
| if "dont_patch_engines" in request.keywords: # pragma: no cover |
There was a problem hiding this comment.
We weren't actually testing it, and it was flagged as not covered after I cleaned up test_startup. I don't think it should be that PR responsibility to add coverage for this case in this fixture
There was a problem hiding this comment.
🤔 weird that it was flagged as not covered as that marker is used in tests.
There was a problem hiding this comment.
(Anyway, agree it is not the responsibility of current PR to cover this)
There was a problem hiding this comment.
🤔 weird that it was flagged as not covered as that marker is used in tests.
It was previously covered in test_startup, but since we were setting the mark.usefixtures("patch_engine_from_config", "patch_new_engine") at the top of the file, but then for every test we were using @mark.dont_patch_engines, we weren't actually testing anything in terms of what the expected behavior is.
Description
Related PRs
Extracted from #105
Related JIRA issues
Validation
New behaviour is thoroughly tested with unit and integration tests ✅