-
Notifications
You must be signed in to change notification settings - Fork 213
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
feat: Added comprehensive test coverage for Group-related models #1020
base: main
Are you sure you want to change the base?
Conversation
Added following tests for Group model: - Group Creation: Tests successful creation, missing required fields, and invalid data. - Group Update: Tests successful update and handling of invalid input. - Group Deletion: Tests successful deletion and an attempt to delete a non-existent group.
- Add test_group_creation to validate complete Group object creation - Add test_required_fields to ensure validation for mandatory fields - Add test_optional_fields to verify handling of optional fields This commit introduces three unit tests for the Group model: 1. Validates full object creation with all fields 2. Checks validation errors for missing required fields 3. Confirms optional fields can be blank/null
Add tests to verify: - Maximum length constraints for Group model fields - Cascade deletion behavior when parent Organization or User is deleted
- Add test cases for GroupMember model covering roles and membership - Add test cases for GroupResource model with creation and deletion flows - Add test cases for GroupText model including language handling - Add test cases for GroupTopic model with relationship validations - Add test cases for GroupEvent model with multiple event relation - Expand Group model tests with field validations and cascade deletions The test suite now validates: - Model relationships and constraints - Field validations and max lengths - Multi-language support for text content - Cascade deletion behavior - Required vs optional field handling
Thank you for the pull request!The activist team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :) If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Development rooms once you're in. Also consider joining our bi-weekly Saturday dev syncs. It'd be great to have you! Maintainer checklist
|
✅ Deploy Preview for activist-org canceled.
|
Sure, @andrewtavis, I’d be happy to! During testing, I noticed the current coverage is around 80-83%. I can explore areas with lower coverage and work on improving them. I’m also open to any suggestions you or @to-sta might have—just let me know! |
.gitignore
Outdated
@@ -41,3 +41,5 @@ dist | |||
|
|||
# Node dependencies | |||
node_modules | |||
/.vscode |
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.
Checking in on these being added in @zeus2611 :) We do have settings.json
and extensions.json
version controlled, so should we maybe take these lines out?
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 initially thought this folder was automatically modified and added to version control. However, since these files are already version-controlled, I’ll update the .gitignore
file to exclude them. Thanks for pointing that out!
@@ -1,5 +1,10 @@ | |||
{ | |||
"eslint.validate": ["javascript", "typescript", "vue"], | |||
"eslint.useFlatConfig": true, | |||
"typescript.tsdk": "./frontend/node_modules/typescript/lib" | |||
"typescript.tsdk": "./frontend/node_modules/typescript/lib", | |||
"python.testing.pytestArgs": [ |
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.
Could you give me a quick explanation of why these lines are needed, @zeus2611? Thank you!
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.
VS Code automatically added these lines while I was working on the tests. It seems they were included as part of the editor's configuration updates. Let me know if you’d like me to investigate further!
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.
Let's remove these then :) Can you do another commit to do this?
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.
Ah you already did :)
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.
Thank you!
backend/entities/tests/test_group.py
Outdated
org = OrganizationFactory(created_by=user) | ||
fake = Faker() | ||
|
||
# Test invalid URL |
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.
Minor thing that we do for comments is that if they're their own line as is the case here, then it'd be best if they were fully punctuated as this is Python standard :) If it's an inline comment, then no need for capitalization or a period at the end, but if it's on its own line then including both would be best :) I can also do this if you'd like me to!
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, @andrewtavis! That makes sense. I'll update the comments to follow the Python standard, ensuring punctuation and capitalization where needed for standalone comments. Appreciate the heads-up! 😊
Let me know on the above points and then I'll get to the full review, @zeus2611! |
…ation and capitalization.
…ctivist into 828-group-model-tests
assert group.terms_checked is False | ||
|
||
|
||
def test_field_max_lengths() -> None: |
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.
Hi @zeus2611,
I reviewed your changes, and they generally look great! 😃 One suggestion before we merge: please remove the tests related to Django, such as those for max_length or auto_fields.
We don't need these tests because Django’s ORM and model field types are already well-tested by the framework itself. We rely on Django's built-in tests to ensure that things like max_length and auto_fields are functioning correctly. Additionally, during the code review process, we check for the correct usage of these features. If there were any issues, we would catch them at that stage.
By removing these tests, we keep the test suite focused on more application-specific logic, avoiding redundancy.
Thanks!
Contributor checklist
Description
This PR adds extensive test coverage for all Group-related models in the entities module. The new tests ensure proper validation, relationship handling, and data integrity across the Group model ecosystem.
Key additions:
Test Coverage
New test files:
All tests use pytest and the Django test database marker.
Testing Notes
Related issue