-
Notifications
You must be signed in to change notification settings - Fork 377
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
add unit tests for Tag class #199
Conversation
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.
Thanks for the PR. Ideally please add a CI job which will run the tests. Otherwise having tests no one runs is like having no tests at all.
def test_tag3(): | ||
return Tag(id=3, name="tag3 Name", shorthand="tag3", aliases=[], subtags_ids=[], color="") | ||
|
||
class TestTags(): |
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.
isnt this wrapping class superfluous?
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.
At the moment yes, but it's needed for one of the commented out tests. I think display_name should probably be changed, but I wanted to have tests for it if we want to keep it as is. Maybe I'll comment that fixture out for now and open an issue to change display_name?
tagstudio/tests/core/test_tags.py
Outdated
if __name__ == "__main__": | ||
pytest.main() |
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.
why is this needed?
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.
You're right it isn't needed. I've removed it in the latest commits.
Co-authored-by: Jiri <[email protected]>
I've added runtest.yaml This is the first time I've worked with github actions but I think it's working as intended. |
The interface of |
Added unit tests just for the Tag class. Tests the following:
add_subtag
remove_subtag
remove_subtag if id is not in subtag_ids
debug_name
display_name with shorthand
display_name without shorthand
display_name with no subtag_ids
Also added tests for edge cases with display name when tags don't have names but I commented those out for now since we probably don't want to display them in that format. ex result for tag & subtag having no name " ()"
Added pytest-mock to requirements-dev.txt
I'm not sure what version to add, I tested on both v3.0.0 & v3.14.0
I have not been following the path.os changes so the header in test_tags.py might need to be changed