diff --git a/pyproject.toml b/pyproject.toml index 44b2380..0101113 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,4 +34,11 @@ asyncio_default_fixture_loop_scope = "session" [tool.coverage.run] omit = [ "tests/*" -] \ No newline at end of file +] + +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where = ["src"] diff --git a/src/hrm/ts_db.py b/src/hrm/ts_db.py index 1d4b332..c9f731e 100644 --- a/src/hrm/ts_db.py +++ b/src/hrm/ts_db.py @@ -59,7 +59,9 @@ def clear(self): """ self.data.clear() - def time_bucket(self, start: float, end: float, bucket_size: float) -> List[tuple[float, float]]: + def time_bucket( + self, start: float, end: float, bucket_size: float + ) -> List[tuple[float, float]]: """ Bucket the data from the given start timestamp to the given end timestamp into the given time bucket size. """ diff --git a/tests/mcp/test_bt_client.py b/tests/mcp/test_bt_client.py index f037bfa..2cb06c5 100644 --- a/tests/mcp/test_bt_client.py +++ b/tests/mcp/test_bt_client.py @@ -6,8 +6,6 @@ from hrm.bt_client import HEART_RATE_SERVICE_UUID, BtClient, upload_file -import os - @pytest.fixture def bt_client(): @@ -192,6 +190,7 @@ def test_build_heart_rate_chart_upload_fail(mock_plt, mock_upload_file, bt_clien def fake_savefig(buf, format=None): if hasattr(buf, "write"): buf.write("mocked") + mock_plt.savefig.side_effect = fake_savefig # Call the method result = bt_client.build_heart_rate_chart(since_from=2.0) @@ -211,7 +210,9 @@ def test_build_heart_rate_chart_bucket_size(mock_plt, mock_upload_file, bt_clien since = 100.0 url = bt_client.build_heart_rate_chart(since_from=since) assert url == "http://fake.url/chart.png" - mock_bucket.assert_called_once_with(since_from=since, bucket_size=math.ceil(since / 60)) + mock_bucket.assert_called_once_with( + since_from=since, bucket_size=math.ceil(since / 60) + ) def test_upload_file_success(monkeypatch): @@ -222,8 +223,12 @@ def test_upload_file_success(monkeypatch): monkeypatch.setenv("QINIU_BUCKET_DOMAIN", "http://fake.domain") # Patch QiniuAuth and QiniuPutFile - with patch("hrm.bt_client.QiniuAuth") as MockAuth, \ - patch("hrm.bt_client.QiniuPutFile", return_value=({"key": "somekey"}, MagicMock())) as mock_put_file: + with ( + patch("hrm.bt_client.QiniuAuth") as MockAuth, + patch( + "hrm.bt_client.QiniuPutFile", return_value=({"key": "somekey"}, MagicMock()) + ) as mock_put_file, + ): mock_auth_instance = MockAuth.return_value mock_auth_instance.upload_token.return_value = "fake_token" file_path = "/tmp/test.png" diff --git a/tests/mcp/test_ts_db.py b/tests/mcp/test_ts_db.py index 435af71..c6b7dfb 100644 --- a/tests/mcp/test_ts_db.py +++ b/tests/mcp/test_ts_db.py @@ -115,9 +115,13 @@ def test_query_invalid_range(): db = TsDB() db.insert(1.0, 10.0) db.insert(2.0, 20.0) - with pytest.raises(ValueError, match="Start timestamp must be less than end timestamp"): + with pytest.raises( + ValueError, match="Start timestamp must be less than end timestamp" + ): db.query(2.0, 2.0) - with pytest.raises(ValueError, match="Start timestamp must be less than end timestamp"): + with pytest.raises( + ValueError, match="Start timestamp must be less than end timestamp" + ): db.query(3.0, 2.0)