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
- Instantiating the :py:class:`~appdaemon.appdaemon.AppDaemon` class can now be done without any side effects. This will
20
+
also instantiate the necessary subsystem classes, but nothing will really start happening until the :py:meth:`~appdaemon.appdaemon.AppDaemon.start` method is called.
21
+
- The :py:class:`~appdaemon.appdaemon.AppDaemon` object is provided as a `pytest fixture <https://docs.pytest.org/en/stable/how-to/fixtures.html#>`_ (``ad``)
22
+
with the ``function`` scope, which means it will be recreated fresh for each test function. The fixture handles starting
23
+
and stopping the :py:class:`~appdaemon.appdaemon.AppDaemon` instance before/after each test. It also disables all apps,
24
+
so they can be selectively run by the tests.
25
+
- Apps can be modified before they're run by the :py:class:`~appdaemon.app_management.AppManagement` object.
26
+
- The ``run_app_for_time`` fixture combines the functionality of the ``ad`` fixture with the
27
+
:py:meth:`~appdaemon.app_management.AppManagement.app_run_context` so that apps can be temporarily modified and run
28
+
for short periods.
29
+
30
+
31
+
Running Tests
32
+
-------------
33
+
34
+
Use the `uv run <https://docs.astral.sh/uv/reference/cli/#uv-run>`_ command to ensure uv handles the environment. It will make sure the dependencies are all satisfied.
35
+
36
+
.. code-block:: bash
37
+
:caption: Run all tests
38
+
39
+
uv run pytest
40
+
41
+
42
+
Unit Tests
43
+
~~~~~~~~~~
44
+
45
+
Unit tests don't require AppDaemon to be running and should be run frequently during development. Currently the only unit tests are ones that cover datetime and timedelta parsing.
46
+
47
+
.. code-block:: bash
48
+
:caption: Run unit tests
49
+
50
+
uv run pytest -m unit
51
+
52
+
53
+
Functional
54
+
~~~~~~~~~~
55
+
56
+
Functional tests cover various end-to-end interactions between components, so they require AppDaemon to be running. An example would be starting an app, having it register a callback for an event, firing that event, and checking that the callback was called. These should cover as many corner cases as possible
The CI tests get run as part of the GitHub action on PRs to the ``dev`` branch. They're intended to each run more or less instantly and collectively only take a few seconds.
84
+
85
+
.. code-block:: bash
86
+
:caption: Run CI tests
87
+
88
+
uv run pytest -m ci
89
+
90
+
Plugin Tests
91
+
~~~~~~~~~~~~
92
+
93
+
Testing plugins involves either connecting to or mocking external systems, so aren't yet covered.
0 commit comments