-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
[Issue 179] Adding a test for the osprojects model #184
Conversation
Codecov Report
@@ Coverage Diff @@
## main #184 +/- ##
=======================================
Coverage ? 82.21%
=======================================
Files ? 34
Lines ? 568
Branches ? 0
=======================================
Hits ? 467
Misses ? 101
Partials ? 0 Continue to review full report at Codecov.
|
@@ -7,6 +7,7 @@ | |||
from tagging.managers import CustomTaggableManager | |||
from tagging.models import CustomTag, TaggedItems | |||
|
|||
|
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.
Note: my linter caused this extra line, but not sure why it's appearing π€
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.
Apologies for the brain fart and not reviewing this sooner! I think your linter is enforcing some sort of PEP 8 thing where imports are separated from code by two lines? Dunno. Weird.
""" Test OSProjects model """ | ||
# create OSProjects model instance | ||
osproject = OSProjectsFactory(title="Buddybot", guid="cc63f918-d515-11ea-956f-0242ac130002") | ||
assert osproject.title == "Buddybot" |
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.
Note: was thinking I could add more asserts here, but was wondering if this might also be fine
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.
Up to you. I usually go for an entire record -- or even two, then pick up to four things to assert. But even one assert proves it was inserted into the DB, which is what we are going for here....so.....
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.
I think this works. You could get more elaborate, or even update data and check to make sure it works. Although that's getting into re-testing the ORM territory. I think this is probably "good enough" for a first pass at a model test for OSProjects
. We can revisit as we get more of the endpoint done.
Thank you for reviewing, @BethanyG!! Will merge this in... and as you said, revisit/update as we get more of the endpoint done. |
What type of PR is this? (check all applicable)
Context
Tests the
osprojects
model we created! Two todos:[x] Cleared up this issue:
osprojects/tests.py::test_osprojects_model /usr/local/lib/python3.7/site-packages/django/db/models/fields/__init__.py:1363: RuntimeWarning: DateTimeField OSProjects.modified received a naive datetime (2020-05-31 00:00:00) while time zone support is active. RuntimeWarning)
by usingdatetime.now()
[ ] Add more asserts (maybe?)
Other Related Tickets & Documents (as needed)
#179
Implementation Details
[x] Created a factories.py file to generate new osprojects
[x] Tested that a newly created
osproject
had the relevant fields[x] Ran
docker-compose run --rm app pytest
and confirmed that tests passedNew Libraries/Dependancies Introduced (Fill out as needed)
N/A
If you have added libraries or other dependancies, please list them (and links to their repos) below:
requirements.txt
Any new migration files added?
Did you add tests?
Code added or changed without test coverage or good reason for exemption won't be approved.
Yes, but could use feedback on these tests!
Did you add documentation?