autopush-rs icon indicating copy to clipboard operation
autopush-rs copied to clipboard

feat: fixturize pytest

Open taddes opened this issue 2 months ago • 0 comments

Closes SYNC-4116

Summary & Acceptance Criteria Met:

  • unittest fully removed.
  • All tests pulled out of classes and into individual test classes, all references to duplicated class boilerplate in normal tests and broadcast tests moved into their own fixtures.
  • Some setup and teardown logic moved into autouse fixtures.
  • Test data is injected into individual tests through pytest.mark.parameterize. This removes internal test setup and also provides the injected values in the test output, for easier debugging.
  • max_logs decorator removed and process_logs are now implemented though an autouse fixture that runs at the end of each test, allowing the endpoint and connection values to be passed in.
  • 🎉 Bonus: resolved the [ ERROR] Task was destroyed but it is pending! problem by moving the test_client and registered_test_client into async fixtures that yield the client and then automatically disconnect after each test function.
  • 🎉 Bonus: tests run faster! Cut the execution time in half: 65.22s -> 36.29s

Note: potential move into conftest would be covered in scope of another task. May not get much benefit from this presently. Also, moving scope of some of the setup would be too much in a single PR given the changes in design here.

taddes avatar Apr 25 '24 20:04 taddes