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

test: Integration test for /health #97

Merged
merged 13 commits into from
Nov 30, 2023

Conversation

FranzForstmayr
Copy link
Contributor

@FranzForstmayr FranzForstmayr commented Nov 13, 2023

Pull Request Checklist

  • New code has 100% test coverage
  • (If applicable) The prose documentation has been updated to reflect the changes introduced by this PR
  • (If applicable) The reference documentation has been updated to reflect the changes introduced by this PR
  • Pre-Commit Checks were ran and passed
  • Tests were ran and passed

Description

The health API is currently not working due to an msgspec Validation error, as the wrong type is passed. This PR tries to fix this, however it's still WIP, as the tests are not passing yet, although the swagger UI works already.

Maybe someone has hints how to overcome the pytest issues.

@FranzForstmayr FranzForstmayr requested review from cofin and a team as code owners November 13, 2023 21:49
@FranzForstmayr
Copy link
Contributor Author

The issue is now that

    def provide_queues(self, state: State) -> TaskQueues:
        """Provide the configured job queues.

        Args:
            state: The ``Litestar.state`` instance.

        Returns:
            a ``TaskQueues`` instance.
        """
        return cast("TaskQueues", state.get(self.queues_dependency_key))

from
https://github.com/cofin/litestar-saq/blob/27cfd7b79b9d3c35bd19d24cfca8b67cbc30b171/litestar_saq/config.py#L120

returns None but check_system_health doesn't accept None

async def check_system_health(self, db_session: AsyncSession, task_queues: TaskQueues) -> Response[SystemHealth]:

@Faolain
Copy link
Contributor

Faolain commented Nov 27, 2023

Quick look at this and it seems like this works when running the app live in that provide_queues returns the task_queues upon app state initialization (injected via litestar-saq plugin) but when running the test it returns None? Is some setup required within the test to get task_queues populated correctly?

@FranzForstmayr
Copy link
Contributor Author

This PR requires now the change in cofin/litestar-saq#15 as provide_queues should not return None but an empty TaskQueues instance (At least according to the return type).

However after changing the URL key in .env.testing unrelated tests in tests/unit/lib/test_dependencies start to fail (Event Loop is closed), but only if all tests are executed. When I exucute the unit tests in this file alone everything is fine.

@FranzForstmayr FranzForstmayr changed the title Integration test for /health test: Integration test for /health Nov 27, 2023
@cofin
Copy link
Member

cofin commented Nov 27, 2023

This PR requires now the change in cofin/litestar-saq#15 as provide_queues should not return None but an empty TaskQueues instance (At least according to the return type).

However after changing the URL key in .env.testing unrelated tests in tests/unit/lib/test_dependencies start to fail (Event Loop is closed), but only if all tests are executed. When I exucute the unit tests in this file alone everything is fine.

Thanks for the work on this. I've merged in your proposed change and made a v0.1.13 release.

@cofin cofin removed the request for review from a team November 28, 2023 17:05
@FranzForstmayr
Copy link
Contributor Author

I've to admit I've no clue what's wrong here.
When the tests are executed manually like pdm run pytest -k filters but ``pdm run pytest` fails at the first filter test.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@cofin cofin merged commit b39261c into litestar-org:main Nov 30, 2023
8 checks passed
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.

3 participants