Open AndrewLester opened 1 year ago
Merging #87 (819f55f) into main (5eecace) will increase coverage by
0.78%
. The diff coverage is99.31%
.
@@ Coverage Diff @@
## main #87 +/- ##
==========================================
+ Coverage 93.82% 94.60% +0.78%
==========================================
Files 10 10
Lines 405 538 +133
==========================================
+ Hits 380 509 +129
- Misses 25 29 +4
Impacted Files | Coverage Δ | |
---|---|---|
pv_site_api/auth.py | 89.28% <90.00%> (-1.20%) |
:arrow_down: |
pv_site_api/__init__.py | 100.00% <100.00%> (ø) |
|
pv_site_api/_db_helpers.py | 100.00% <100.00%> (ø) |
|
pv_site_api/cache.py | 89.18% <100.00%> (-7.96%) |
:arrow_down: |
pv_site_api/fake.py | 100.00% <100.00%> (ø) |
|
pv_site_api/main.py | 94.89% <100.00%> (+2.03%) |
:arrow_up: |
pv_site_api/pydantic_models.py | 100.00% <100.00%> (ø) |
|
pv_site_api/utils.py | 100.00% <100.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
I was just able to remove our EnodeAuth
class, which was really just an OAuth2 client credentials authorization wrapper that worked for Enode. Since it was so general, I think it makes sense to not include the code/tests in this repo, and instead pull it from a library like the one I've installed: httpx-auth.
Right now this is failing tests though because the library's class requires a non-empty string for the client_id
and client_secret
, but these aren't provided by the GitHub actions. They can either be added (test values), or I can default them to non-empty test values here:
https://github.com/openclimatefix/pv-site-api/blob/e185d933c079d34254d511b86b0417bf06dc63d6/pv_site_api/main.py#L118-L119
Alternatively, the enode_auth instance there could be provided as a mocked app
dependency.
To make the tests pass without those environment variables, I just opted to default them to unusable values. This doesn't change any behavior since the tests don't even use the enode_auth
object, given that all the test httpx
requests are mocked out.
Pull Request
This pull request adds all of the necessary endpoints we'll need for minimal Enode support in the
pv-sites-mobile
UI. For reference, it adds this functionality:Unrelated to Enode, but necessary for our project, is another endpoint:
We could move this latter endpoint to another PR if necessary.
Description
Adds support for linking inverters, storing linked inverters in our database, and retrieving inverter information from Enode.
Fixes: #71 Fixes: #72 Fixes: #73 Fixes: #74
Several new environment variables are now used:
ENODE_API_BASE_URL
, though not required (defaults to sandbox) found hereENODE_TOKEN_URL
, though not required (defaults to Enode token URL specific in docs) found hereENODE_CLIENT_ID
the Enode client IDENODE_CLIENT_SECRET
the Enode client secretHow Has This Been Tested?
This has been tested with the addition of new test files as well as run through manual testing.
Checklist: