diff --git a/.gitignore b/.gitignore index 09c756e..ceac1cd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ env coverage.xml .secrets .pytest_cache +docker/config diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..e613748 --- /dev/null +++ b/docker/docker-compose.yaml @@ -0,0 +1,17 @@ +version: '3.9' +services: + homeassistant: + container_name: home-assistant + image: homeassistant/home-assistant + ports: + - 8123:8123 + volumes: + - ./config:/config + - ../custom_components/alpha_innotec:/config/custom_components/alpha_innotec + nginx: + image: nginx + ports: + - 80:80 + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf + - ../tests/fixtures:/var/www diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..b6939f5 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,46 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + root /var/www; + error_page 405 =200 $uri; + location /api/room/list { + alias /var/www/; + try_files controller_api_room_list.json =404; + } + + location /admin/systeminformation/get { + alias /var/www/; + try_files controller_admin_systeminformation_get.json =404; + } + + location /api/room/settemperature { + alias /var/www/; + try_files controller_api_room_settemperature.json =404; + } + + location /admin/login/check { + alias /var/www/; + try_files controller_admin_login_check.json =404; + } + + location /api/user/token/challenge { + alias /var/www/; + try_files controller_api_user_token_challenge.json =404; + } + + location /api/user/token/response { + alias /var/www/; + try_files controller_api_user_token_response.json =404; + } + + location /api/gateway/dbmodules { + alias /var/www/; + try_files gateway_api_dbmodules.json =404; + } + + location /api/gateway/allmodules { + alias /var/www/; + try_files gateway_api_allmodules.json =404; + } +} diff --git a/tests/fixtures/controller_admin_login_check.json b/tests/fixtures/controller_admin_login_check.json new file mode 100644 index 0000000..7068c43 --- /dev/null +++ b/tests/fixtures/controller_admin_login_check.json @@ -0,0 +1,6 @@ +{ + "success": true, + "message": "", + "language": "en", + "performance": 0.047 +} diff --git a/tests/fixtures/controller_api_systeminformation.json b/tests/fixtures/controller_admin_systeminformation_get.json similarity index 100% rename from tests/fixtures/controller_api_systeminformation.json rename to tests/fixtures/controller_admin_systeminformation_get.json diff --git a/tests/fixtures/controller_api_room_list.json b/tests/fixtures/controller_api_room_list.json index 53388e3..bb56a7d 100644 --- a/tests/fixtures/controller_api_room_list.json +++ b/tests/fixtures/controller_api_room_list.json @@ -156,4 +156,4 @@ ], "language": "en", "performance": 0.907 -} \ No newline at end of file +} diff --git a/tests/fixtures/controller_api_room_settemperature.json b/tests/fixtures/controller_api_room_settemperature.json new file mode 100644 index 0000000..7068c43 --- /dev/null +++ b/tests/fixtures/controller_api_room_settemperature.json @@ -0,0 +1,6 @@ +{ + "success": true, + "message": "", + "language": "en", + "performance": 0.047 +} diff --git a/tests/fixtures/controller_api_user_token_challenge.json b/tests/fixtures/controller_api_user_token_challenge.json new file mode 100644 index 0000000..de19b3b --- /dev/null +++ b/tests/fixtures/controller_api_user_token_challenge.json @@ -0,0 +1 @@ +{"success": true, "message": "", "loginRejected": false, "devicetoken": "7f594a2e44244d1f92df88d7dccaed48", "language": "en", "performance": 0.042} diff --git a/tests/fixtures/controller_api_user_token_response.json b/tests/fixtures/controller_api_user_token_response.json new file mode 100644 index 0000000..f335f56 --- /dev/null +++ b/tests/fixtures/controller_api_user_token_response.json @@ -0,0 +1 @@ +{"success": true, "message": "", "loginRejected": false, "devicetoken_encrypted": "W9UIefCF9T7jQGmagrhsJPEldxM5iher+CSAIvbas84=", "userid": 4, "language": "en", "performance": 0.202} diff --git a/tests/fixtures/gateway_api_allmodules.json b/tests/fixtures/gateway_api_allmodules.json index b32e41e..6665d04 100644 --- a/tests/fixtures/gateway_api_allmodules.json +++ b/tests/fixtures/gateway_api_allmodules.json @@ -219,4 +219,4 @@ }, "language": "en", "performance": 0.75 -} \ No newline at end of file +} diff --git a/tests/fixtures/gateway_api_dbmodules.json b/tests/fixtures/gateway_api_dbmodules.json index 2a52b43..7411a00 100644 --- a/tests/fixtures/gateway_api_dbmodules.json +++ b/tests/fixtures/gateway_api_dbmodules.json @@ -277,4 +277,4 @@ }, "language": "en", "performance": 0.138 -} \ No newline at end of file +} diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 578a3c4..bb7a24b 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -22,7 +22,7 @@ async def test_setup_config(hass: HomeAssistant): with patch( target=f"{MODULE}.config_flow.validate_input", - return_value=json.loads(load_fixture("controller_api_systeminformation.json")), + return_value=json.loads(load_fixture("controller_admin_systeminformation_get.json")), ) as mock_setup_entry: result = await hass.config_entries.flow.async_configure( result["flow_id"],