Skip to content

Make site_uuid field on PVSiteMetadata model optional #65

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

Merged
merged 6 commits into from
Mar 31, 2023

Conversation

AndrewLester
Copy link
Contributor

@AndrewLester AndrewLester commented Mar 29, 2023

Pull Request

Description

Makes the site_uuid field in the PVSiteMetadata model optional to support automatic uuid generation by SQLAlchemy. I've also changed the site post endpoint to now not supply a site_uuid (previously from request data).

The reason I made the type optional inside PVSiteMetadata instead of removing is because the model is used in other endpoints which do have a valid site_uuid.

Fixes #62

How Has This Been Tested?

Tested locally via accessing the endpoints. I've changed tests to now try both supplying and not supplying a site uuid when creating a site.

  • Yes (on GitHub actions)

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@codecov
Copy link

codecov bot commented Mar 29, 2023

Codecov Report

Merging #65 (89910a0) into main (d4e397d) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #65   +/-   ##
=======================================
  Coverage   91.90%   91.90%           
=======================================
  Files           8        8           
  Lines         321      321           
=======================================
  Hits          295      295           
  Misses         26       26           
Impacted Files Coverage Δ
pv_site_api/main.py 89.61% <ø> (ø)
pv_site_api/__init__.py 100.00% <100.00%> (ø)
pv_site_api/pydantic_models.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AndrewLester AndrewLester marked this pull request as ready for review March 29, 2023 18:47
@@ -21,7 +21,7 @@ class PVSiteAPIStatus(BaseModel):
class PVSiteMetadata(BaseModel):
"""Site metadata"""

site_uuid: str = Field(..., description="Unique internal ID for site.")
site_uuid: Optional[str] = Field(None, description="Unique internal ID for site.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put one small comment, but other wise looks great

@peterdudfield peterdudfield merged commit dacdf29 into main Mar 31, 2023
@peterdudfield peterdudfield deleted the db-id-generation branch March 31, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Use the Database to generate Site UUIDs
2 participants