Some renaming
This commit is contained in:
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@@ -9,7 +9,10 @@
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal"
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,8 +5,8 @@ charset-normalizer==3.3.2
|
||||
click==8.1.7
|
||||
dnspython==2.6.1
|
||||
email_validator==2.2.0
|
||||
fastapi==0.111.1
|
||||
fastapi-cli==0.0.4
|
||||
fastapi==0.112.1
|
||||
fastapi-cli==0.0.5
|
||||
fastapi-mqtt==2.2.0
|
||||
gmqtt==0.6.16
|
||||
h11==0.14.0
|
||||
@@ -21,6 +21,7 @@ MarkupSafe==2.1.5
|
||||
mdurl==0.1.2
|
||||
notion-client==2.2.1
|
||||
packaging==24.1
|
||||
pip-review==1.3.0
|
||||
pluggy==1.5.0
|
||||
pydantic==2.8.2
|
||||
pydantic_core==2.20.1
|
||||
@@ -28,16 +29,16 @@ Pygments==2.18.0
|
||||
pytest==8.3.2
|
||||
python-dotenv==1.0.1
|
||||
python-multipart==0.0.9
|
||||
PyYAML==6.0.1
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
rich==13.7.1
|
||||
shellingham==1.5.4
|
||||
sniffio==1.3.1
|
||||
starlette==0.37.2
|
||||
typer==0.12.3
|
||||
starlette==0.38.2
|
||||
typer==0.12.4
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.2.2
|
||||
uvicorn==0.30.1
|
||||
uvloop==0.19.0
|
||||
watchfiles==0.22.0
|
||||
uvicorn==0.30.6
|
||||
uvloop==0.20.0
|
||||
watchfiles==0.23.0
|
||||
websockets==12.0
|
||||
|
||||
@@ -10,7 +10,7 @@ from src.config import Config
|
||||
|
||||
|
||||
class HomeAssistant:
|
||||
class PublishMessage(BaseModel):
|
||||
class Message(BaseModel):
|
||||
target: str
|
||||
action: str
|
||||
content: str
|
||||
@@ -18,13 +18,13 @@ class HomeAssistant:
|
||||
def __init__(self, ticktick: TickTick) -> None:
|
||||
self._ticktick = ticktick
|
||||
|
||||
def process_publish_message(self, message: PublishMessage) -> dict[str, str]:
|
||||
def process_message(self, message: Message) -> dict[str, str]:
|
||||
if message.target == "ticktick":
|
||||
return self._process_ticktick_message(message=message)
|
||||
|
||||
return {"Status": "Unknown target"}
|
||||
|
||||
def _process_ticktick_message(self, message: PublishMessage) -> dict[str, str]:
|
||||
def _process_ticktick_message(self, message: Message) -> dict[str, str]:
|
||||
if message.action == "create_shopping_list":
|
||||
return self._create_shopping_list(content=message.content)
|
||||
if message.action == "create_action_task":
|
||||
|
||||
0
src/cloud_util/tests/__init__.py
Normal file
0
src/cloud_util/tests/__init__.py
Normal file
7
src/cloud_util/tests/test_ticktick.py
Normal file
7
src/cloud_util/tests/test_ticktick.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from cloud_util.ticktick import TickTick
|
||||
|
||||
|
||||
def test_ticktick_begin_auth() -> None:
|
||||
auth_url = TickTick.begin_auth()
|
||||
@@ -39,8 +39,8 @@ async def get_status() -> dict:
|
||||
|
||||
|
||||
@app.post("/homeassistant/publish")
|
||||
async def homeassistant_publish(payload: HomeAssistant.PublishMessage) -> dict:
|
||||
return homeassistant.process_publish_message(message=payload)
|
||||
async def homeassistant_publish(payload: HomeAssistant.Message) -> dict:
|
||||
return homeassistant.process_message(message=payload)
|
||||
|
||||
|
||||
# Poo recorder
|
||||
|
||||
@@ -18,7 +18,7 @@ EXPECTED_ENV_DICT: OrderedDict[str, str] = OrderedDict(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def _prepare_test_dot_env() -> any:
|
||||
TEST_DOT_ENV_PATH.touch(mode=0o600, exist_ok=True)
|
||||
for key, value in EXPECTED_ENV_DICT.items():
|
||||
@@ -27,7 +27,7 @@ def _prepare_test_dot_env() -> any:
|
||||
TEST_DOT_ENV_PATH.unlink()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def _load_test_dot_env(_prepare_test_dot_env: any) -> None:
|
||||
Config.init(dotenv_path=TEST_DOT_ENV_PATH)
|
||||
|
||||
|
||||
11
src/tests/test_main.py
Normal file
11
src/tests/test_main.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from fastapi import status
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from src.main import app
|
||||
|
||||
|
||||
def test_get_homeassistant_status() -> None:
|
||||
client = TestClient(app)
|
||||
response = client.get("/homeassistant/status")
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() == {"Status": "Ok"}
|
||||
Reference in New Issue
Block a user