You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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.
The text was updated successfully, but these errors were encountered:
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 heretests/fixtures/mock_environment.py:138
and always return 0 as their reading as part of themock_environment
fixture.mock_environment
fixture is activated for all tests usingapp
fixture heretests/fixtures/app.py:266
.Now to test temperature and light sensors we can do any of these:
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 thetest_services
and disable it temporarily to test sensors and then enable it again for snapshots.mock_environment
as a fixture requested byapp
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 havetest_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.The text was updated successfully, but these errors were encountered: