-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional: two additional testing environment options #182
Optional: two additional testing environment options #182
Conversation
Note: these methods are still developmental. Somethings act slightly differently then they should. However, the hope is that this will be an assistance for developers that choose to use it. |
This looks nice for add-on testing. |
Good Idea 👍 7171b35 |
Hi. Could consider your changes to the web_server.py. |
Yeah sorry about that. I Should be able to add it back in without a problem. Will check now however |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #182 +/- ##
==========================================
+ Coverage 89.84% 89.90% +0.06%
==========================================
Files 6 6
Lines 1645 1645
==========================================
+ Hits 1478 1479 +1
+ Misses 167 166 -1 ☔ View full report in Codecov by Sentry. |
@davidusb-geek Added support to use Environment Variables. I understand that this adds a bit of code. |
I was also thinking about adding security with the secrets with the use of docker secrets. But since the docker container in question is for development only I thought it was outside of scope. |
From what I see in the code the default values are what it was before so it should be ok. |
src/emhass/web_server.py
Outdated
@@ -216,12 +224,9 @@ def action_call(action_name): | |||
hass_url = params_secrets['hass_url'] | |||
|
|||
# Build params | |||
if use_options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This invalidates the use of the use_options
helper
Merging... |
This is an optional pull request uses VS-Code Dev container or Dockerfile (as an sandboxed environment) for debugging and testing the application. Both of which where designed with focus on running with Add-on mode. And both need an additional HA environment to operate (no supervisor support for the moment)
Method 1: VS-Code Debug and Run
Recommended steps to run are:
emhass
) foulder in VS-CodeTo run and test: (via VS-Code Run and Debug)
control+shift+p
>Tasks: Run Task
>EMHASS Install
. This has been set up in the tasks.json file. Re-run this every time a change has been made emhass before run & debug.Run and Debug
tab (Ctrl+Shift+D.) >EMHASS run Addon
. This has been setup in the Launch.json. You will need to modify theEMHASS_URL
(http://HAIPHERE:8123/) andEMHASS_KEY
(PLACEKEYHERE) before running to match your HA environment in order to work. you can also choose to runEMHASS run
. This acts more like standalone mode and uses the secrets file (however less tested)Testing
tab on the left hand sideMethod 2: Dockerfile run
Alternatively: This PR also adds a dockerfile that tries to emulate the Add-on environment as best as possible. This method is slower, however does not need VS-code to run (just Docker environment)
Run it on the emhass root dir with: (It is recommended to run this on the host device, rather than an dev container)
docker build -t emhass/testing -f Add-onEmulateDocker . docker run -it -p 5000:5000 --name emhass-test docker.io/emhass/testing --url YOURHAURLHERE --key YOURHAKEYHERE
Delete docker container and image with:
For Rapid testing try a command chain like this:
Bash Example
With example above use
secrets_emhass.yaml
oroptions.yaml
file to set time_zone,Lat,Lon & AltDocker Alternative
We can also pass location, key and url parameters via environment variables
This allows the user to set variables prior to build
Linux Example: (in you host terminal)
Note:
secrets_emhass.yaml
instead of passing secret parameters as environment variables/ arguments