Skip to content

Commit 110f99b

Browse files
authored
feat: adding tests (#224)
* feat: adding tests adding tests for datastore for #25. one small fix for never-used parameter * feat: adding tests fixing mypy error
1 parent d885738 commit 110f99b

File tree

5 files changed

+585
-9
lines changed

5 files changed

+585
-9
lines changed

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ include_trailing_comma = true
3737
plugins = ["pydantic.mypy"]
3838

3939

40-
[tool.pydantic-mypy]
40+
[tool.pydantic-mypy]
41+
42+
[tool.pytest]
43+
minversion = "9.0"
44+
addopts = ["-ra", "--cov=soundcork", "--cov-report=term-missing:skip-covered"]
45+
testpaths = [
46+
"tests",
47+
]

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ gunicorn==23.0.0
55
isort==8.0.0 # dev only
66
mypy==1.19.1 # dev only
77
pydantic-settings==2.13.1
8+
pytest==9.0.1 # dev only
9+
pytest-cov==7.0.0 # dev only
810
telnetlib3==3.0.2
911
upnpclient==1.0.3

soundcork/datastore.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class DataStore:
3939
def __init__(self) -> None:
4040
logger.info("Initiating Datastore")
4141
self.data_dir = settings.data_dir
42-
# def __init__(self, data_dir: str, settings: Settings) -> None:
43-
44-
def initialize_data_directory(self) -> None:
45-
raise NotImplementedError
4642

4743
def poweron_devices_dir(self) -> str:
4844
"""returns the top-level directory that stores poweron info for all devices"""
@@ -64,11 +60,9 @@ def account_dir(self, account: str, create: bool = False) -> str:
6460
def account_devices_dir(self, account: str) -> str:
6561
return path.join(self.data_dir, account, DEVICES_DIR)
6662

67-
def account_device_dir(
68-
self, account: str, device: str, create: bool = False
69-
) -> str:
63+
def account_device_dir(self, account: str, device: str) -> str:
7064
dir = path.join(self.account_devices_dir(account), device)
71-
if not path.exists(dir) and not create:
65+
if not path.exists(dir):
7266
raise HTTPException(
7367
HTTPStatus.NOT_FOUND,
7468
f"Device {device} does not belong to account {account}",

soundcork/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)