Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ def validate_mysql_password(cls, v: SecretStr) -> SecretStr:
# Union[PostgresDsn, MySQLDsn]:
def SQLALCHEMY_DATABASE_URI(self) -> MySQLDsn:
"""Set SqlAlchemy db url"""
validated_password = self._validate_password("MYSQL_PASSWORD", self.MYSQL_PASSWORD)
validated_password = self._validate_password(
"MYSQL_PASSWORD", self.MYSQL_PASSWORD)
encoded_password = quote_plus(validated_password.get_secret_value())
return (
f"mysql+pymysql://{self.MYSQL_USER}:{encoded_password}@"
f"{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DB}"
f"{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DB}"
)

@computed_field # type: ignore[prop-decorator]
Expand Down
2,238 changes: 1,240 additions & 998 deletions emon-app/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion emon-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@radix-ui/react-visually-hidden": "^1.1.2",
"@tanstack/react-query": "^5.64.2",
"@tanstack/react-table": "^8.21.2",
"@vitest/coverage-v8": "^3.2.4",
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -72,7 +73,7 @@
"prettier-plugin-organize-imports": "^4.1.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": ">=6.2.6",
"vite": ">=6.3.5",
"vitest": "^3.1.2"
}
}
3 changes: 2 additions & 1 deletion requirements-api.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests>=2.32.3
simplejson>=3.19.3
simplejson>=3.19.3
python-slugify>=8.0.4
3 changes: 2 additions & 1 deletion requirements-async-api.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
aiohttp>=3.8.1
simplejson>=3.19.3
simplejson>=3.19.3
python-slugify>=8.0.4
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ dnspython>=2.7.0
email-validator>=2.2.0
PyJWT>=2.10.1
passlib>=1.7.4
python-multipart>=0.0.20
python-multipart>=0.0.20
python-slugify>=8.0.4
3 changes: 2 additions & 1 deletion requirements-fastapi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ email-validator>=2.2.0
PyJWT>=2.10.1
passlib>=1.7.4
python-multipart>=0.0.20
pymysql>=1.1.1
pymysql>=1.1.1
python-slugify>=8.0.4
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ all =
simplejson>=3.19.3
pandas>=2.2.3
matplotlib>=3.9.3
pydantic >= 2.10.6
pydantic-settings >= 2.7.1
pydantic>=2.10.6
pydantic-settings>=2.7.1
18 changes: 10 additions & 8 deletions tests/emon_api/test_async_emon_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest.mock import AsyncMock, patch
from aiohttp import web, ClientSession
from aiohttp.client_exceptions import ClientError
import pytest_asyncio
import pytest
from emon_tools.emon_api.emon_api_core import InputGetType
from emon_tools.emon_api.emon_api_core import RequestType
Expand Down Expand Up @@ -60,7 +61,7 @@

class TestAsyncEmonRequest:
"""AsyncEmonRequest unit test class"""
@pytest.fixture
@pytest_asyncio.fixture
def mock_emon_request(self):
"""Fixture for creating a mock EmonRequest instance."""
return AsyncEmonRequest(url=VALID_URL, api_key=API_KEY)
Expand All @@ -71,12 +72,12 @@ async def mock_handler(self, request):
raise web.HTTPUnauthorized(text="Invalid API key")
return web.json_response({"success": True, "message": "Mock response"})

@pytest.fixture
def aiohttp_server_mock(self, event_loop, aiohttp_server):
@pytest_asyncio.fixture
async def aiohttp_server_mock(self, aiohttp_server):
"""Fixture to mock an aiohttp server."""
app = web.Application()
app.router.add_get("/valid-path", self.mock_handler)
return event_loop.run_until_complete(aiohttp_server(app))
return await aiohttp_server(app)

@pytest.mark.asyncio
async def test_async_request_success(
Expand Down Expand Up @@ -161,7 +162,7 @@ async def test_get_session_reuse(self, mock_emon_request):
class TestAsyncEmonInputs:
"""AsyncEmonInputs unit test class"""

@pytest.fixture
@pytest_asyncio.fixture
def emon_inputs(self):
"""Fixture to initialize an AsyncEmonInputs instance."""
return AsyncEmonInputs(VALID_URL, API_KEY)
Expand Down Expand Up @@ -322,15 +323,16 @@ async def test_input_bulk(self, emon_inputs):
path='/input/bulk',
params={},
data={
'data': '[[1, "test_node", {"temp": 21.2}, {"humidity": 54}]]'},
'data': '[[1, "test_node", {"temp": 21.2}, {"humidity": 54}]]'
},
msg="input_bulk",
request_type=RequestType.POST
)


class TestAsyncEmonFeeds:
"""AsyncEmonFeeds unit test class"""
@pytest.fixture
@pytest_asyncio.fixture
def emon_feeds(self):
"""Fixture to initialize an EmonReader instance."""
return AsyncEmonFeeds(VALID_URL, API_KEY)
Expand Down Expand Up @@ -587,4 +589,4 @@ async def test_add_feed_process_list(self, emon_feeds):
path="/feed/process/set.json",
params={"feed_id": 123, "processlist": '2:1'},
msg="add_feed_process_list"
)
)
2 changes: 2 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
asyncio_mode = auto