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 temperature and light sensors #242

Open
sassanh opened this issue Feb 25, 2025 · 0 comments
Open

Test temperature and light sensors #242

sassanh opened this issue Feb 25, 2025 · 0 comments
Assignees
Labels

Comments

@sassanh
Copy link
Collaborator

sassanh commented Feb 25, 2025

Temperature and light sensors, due to their strong dependence on the environment, are hard to be checked in test environment with snapshot tests.
Currently they are mocked in test environment here: tests/fixtures/mock_environment.py:137 and here tests/fixtures/mock_environment.py:138 and always return 0 as their reading as part of the mock_environment fixture.
mock_environment fixture is activated for all tests using app fixture here tests/fixtures/app.py:266.

Now to test temperature and light sensors we can do any of these:

  1. Make the mock_environment fixture actually return a handle that can be used to enable/disable parts of it, having all parts enabled by default. Then we can explicitly request it in the test_services and disable it temporarily to test sensors and then enable it again for snapshots.
  2. Remove mock_environment as a fixture requested by app fixture, and let each test request it explicitly, then have a separate test for testing sensors that requests it with a configuration (using the pytest mechanism for passing arguments to fixtures) that disables this particular mocking of sensors.

If we want to test it separately, considering it's a test specifically related to sensors service, for the sake of organization, we better provide search paths for pytest in services so that we can have tests of each service in its own directory.

If we want to have it in test_services test, again for the sake of organization, we also better provide service related tests (including this one) in their own directory in a specific file and have test_services load those files.

I think testing it in a separate test is a better idea, keeping test_services focused on testing loading of services and seeing them load without any errors and have specific functional tests of services in their own directory in separate tests.

@sassanh sassanh added this to Ubo App Feb 25, 2025
@sassanh sassanh converted this from a draft issue Feb 25, 2025
@sassanh sassanh added the tests label Feb 25, 2025
@sassanh sassanh moved this to Todo in Ubo App Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants