|
1 | 1 | import logging |
2 | | -from datetime import datetime, timezone, timedelta |
3 | 2 | import random |
4 | | -from time import sleep |
| 3 | +from datetime import datetime, timedelta, timezone |
5 | 4 | from pprint import pprint |
| 5 | +from time import sleep |
6 | 6 |
|
7 | 7 | import pytest |
8 | | - |
9 | 8 | from aw_core.models import Event |
10 | | -from aw_client import ActivityWatchClient |
11 | 9 |
|
12 | 10 | logging.basicConfig(level=logging.WARN) |
13 | 11 |
|
|
16 | 14 | # layer of integration tests that are actually more like unit tests. |
17 | 15 |
|
18 | 16 |
|
19 | | -@pytest.fixture(scope="session") |
20 | | -def aw_client(): |
21 | | - # TODO: Could it be possible to write a sisterclass of ActivityWatchClient |
22 | | - # which calls aw_server.api directly? Would it be of use? Would add another |
23 | | - # layer of integration tests that are actually more like unit tests. |
24 | | - c = ActivityWatchClient("client-test", testing=True) |
25 | | - yield c |
26 | | - |
27 | | - # Delete test buckets after all tests needing the fixture have been run |
28 | | - buckets = c.get_buckets() |
29 | | - for bucket_id in buckets: |
30 | | - if bucket_id.startswith("test-"): |
31 | | - c.delete_bucket(bucket_id) |
32 | | - |
33 | | - |
34 | 17 | @pytest.fixture(scope="function") |
35 | 18 | def bucket(aw_client): |
36 | 19 | bucket_id = "test-" + str(random.randint(0, 10**5)) |
@@ -285,3 +268,10 @@ def test_midnight_heartbeats(aw_client, bucket): |
285 | 268 | ) |
286 | 269 | pprint(recv_events_after_midnight) |
287 | 270 | assert len(recv_events_after_midnight) == int(len(recv_events_merged) / 2) |
| 271 | + |
| 272 | + |
| 273 | +def test_settings(aw_client): |
| 274 | + aw_client.set_setting("test", "test") |
| 275 | + assert aw_client.get_setting("test") == "test" |
| 276 | + assert aw_client.get_setting("test2") is None |
| 277 | + assert aw_client.get_setting() == {"test": "test"} |
0 commit comments