-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add put endpoint for editing site #88
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
Conversation
Create clearsky forecast endpoint
Issue/future forecasts
This doesn't change the result but speeds up the query in general.
Add WHERE statement on query for past forecasts
Make site_uuid field on PVSiteMetadata model optional
Issue/add logging
Codecov Report
@@ Coverage Diff @@
## h4i/enode #88 +/- ##
=============================================
+ Coverage 87.31% 89.56% +2.24%
=============================================
Files 9 11 +2
Lines 410 527 +117
=============================================
+ Hits 358 472 +114
- Misses 52 55 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
tests/test_sites.py
Outdated
@@ -26,7 +25,6 @@ def test_get_site_list(client, sites): | |||
|
|||
def test_put_site_fake(client, fake): |
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 isn't part of your stuff, but for consistency, rename to test_post_site_fake
?
pv_site_api/main.py
Outdated
if site is None: | ||
raise HTTPException(status_code=404, detail="Site not found") | ||
|
||
# update site information |
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.
# update site information |
pv_site_api/main.py
Outdated
site.longitude = site_info.longitude | ||
site.capacity_kw = site_info.installed_capacity_kw | ||
|
||
# commit changes to database |
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.
# commit changes to database |
pv_site_api/main.py
Outdated
client = session.query(ClientSQL).first() | ||
assert client is not None | ||
|
||
# get the site to update |
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.
# get the site to update |
* Bump version: 0.0.36 → 0.0.37 * TDD: add failing test, looking at forecasts in the future * add start utc filter on forecast future qery * lint * lint * isort * add freeze gun to dev dependencies * self PR comments * Bump version: 0.0.37 → 0.0.38 * Make site_uuid field on PVSiteMetadata model optional * Make pydantic field optional * Move test site with real UUID to real db test * Don't use uuid in tests * Add part of check back * Ensure autogenerated site uuid is not null in database * Add WHERE statement on query for past forecasts This doesn't change the result but speeds up the query in general. * Bump version: 0.0.38 → 0.0.39 * Bump version: 0.0.39 → 0.0.40 * add logging * lint * run blacks * add extra logs * Bump version: 0.0.40 → 0.0.41 * add structlogging * add structlog to requiremwnts * add logging * Bump version: 0.0.41 → 0.0.42 * Add structlog initialisation * blacks * isort * Bump version: 0.0.42 → 0.0.43 * Uniformize check to FAKE and fix related test * Set codecov targets * Hard-code the "now" time for all tests This means that the same tests are run now matter the time at which we run them. * add caching * fix * lint * isort * fix for routes calling routes * lint * Bump version: 0.0.43 → 0.0.44 * PR comment * add args to cache * lint * Update pv_site_api/cache.py Co-authored-by: Simon Lemieux <1105380+simlmx@users.noreply.github.com> * tidy * Bump version: 0.0.44 → 0.0.45 * What I've got * Add basic authorization to the /sites* routes The caller of the routes must have a proper Bearer authorization header set. * refactor * add tests * fix error in import * update pvsite-datamodel (in line with main) * fix bug * fix incompatible types * lint and format * add site existence check * add back correct datamodel dependency * fix test name * allow tests to pass by adding fake condition * remove 404 check * use or instead of is not none * Bump version: 0.0.45 → 0.0.46 * add site existence check * format and lint * Bump version: 0.0.46 → 0.0.47 * add post endpoint * add test back in * fix errors and format * add site name to test * fix tiny error * fix another small error * run tests * fix bugs * lint and format * fix fake * :pleading-face: * yet another is_fake() addition * address comments --------- Co-authored-by: Peter Dudfield <34686298+peterdudfield@users.noreply.github.com> Co-authored-by: BumpVersion Action <bumpversion@github-actions> Co-authored-by: peterdudfield <peter.dudfield@hotmail.com> Co-authored-by: AndrewLester <alester220@gmail.com> Co-authored-by: Simon Lemieux <1105380+simlmx@users.noreply.github.com> Co-authored-by: devsjc <sol@openclimatefix.org>
* Bump version: 0.0.36 → 0.0.37 * TDD: add failing test, looking at forecasts in the future * add start utc filter on forecast future qery * lint * lint * isort * add freeze gun to dev dependencies * self PR comments * Bump version: 0.0.37 → 0.0.38 * Make site_uuid field on PVSiteMetadata model optional * Make pydantic field optional * Move test site with real UUID to real db test * Don't use uuid in tests * Add part of check back * Ensure autogenerated site uuid is not null in database * Add WHERE statement on query for past forecasts This doesn't change the result but speeds up the query in general. * Bump version: 0.0.38 → 0.0.39 * Bump version: 0.0.39 → 0.0.40 * add logging * lint * run blacks * add extra logs * Bump version: 0.0.40 → 0.0.41 * add structlogging * add structlog to requiremwnts * add logging * Bump version: 0.0.41 → 0.0.42 * Add structlog initialisation * blacks * isort * Bump version: 0.0.42 → 0.0.43 * Uniformize check to FAKE and fix related test * Set codecov targets * Hard-code the "now" time for all tests This means that the same tests are run now matter the time at which we run them. * add caching * fix * lint * isort * fix for routes calling routes * lint * Bump version: 0.0.43 → 0.0.44 * PR comment * add args to cache * lint * Update pv_site_api/cache.py Co-authored-by: Simon Lemieux <1105380+simlmx@users.noreply.github.com> * tidy * Bump version: 0.0.44 → 0.0.45 * What I've got * Add basic authorization to the /sites* routes The caller of the routes must have a proper Bearer authorization header set. * refactor * add tests * fix error in import * update pvsite-datamodel (in line with main) * fix bug * fix incompatible types * lint and format * add site existence check * add back correct datamodel dependency * fix test name * allow tests to pass by adding fake condition * remove 404 check * use or instead of is not none * Bump version: 0.0.45 → 0.0.46 * add site existence check * format and lint * Bump version: 0.0.46 → 0.0.47 * add post endpoint * add test back in * fix errors and format * add site name to test * fix tiny error * fix another small error * run tests * fix bugs * lint and format * fix fake * :pleading-face: * yet another is_fake() addition * address comments --------- Co-authored-by: Peter Dudfield <34686298+peterdudfield@users.noreply.github.com> Co-authored-by: BumpVersion Action <bumpversion@github-actions> Co-authored-by: peterdudfield <peter.dudfield@hotmail.com> Co-authored-by: AndrewLester <alester220@gmail.com> Co-authored-by: Simon Lemieux <1105380+simlmx@users.noreply.github.com> Co-authored-by: devsjc <sol@openclimatefix.org> Fix some functions Fix Enode link endpoint Remove duplicate fixture Rename /inverters to /enode/inverters
Pull Request
Adds PUT endpoint for editing site details!
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration
Checklist: