Skip to content
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

Facility Users Username Filter #2719

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions care/emr/api/viewsets/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ def get_queryset(self):
).values("user_id")
)

class FacilityUserFilter(FilterSet):
username = CharFilter(field_name="username", lookup_expr="icontains")

class FacilityUsersViewSet(EMRModelReadOnlyViewSet):
database_model = User
pydantic_read_model = UserSpec
filterset_class = FacilityUserFilter
filter_backends = [DjangoFilterBackend]
Comment on lines +116 to +117
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Oh, would you look at that... no test coverage for filters.

While the implementation is technically correct, it seems we're living dangerously without any tests for the FacilityUserFilter functionality. It would be absolutely wonderful if we could add some test cases to ensure this keeps working as intended.

Suggested test cases should cover:

  • Basic filter functionality
  • Edge cases for each filterable field
  • Filter combination scenarios
🔗 Analysis chain

The implementation looks perfect... almost.

The filter configuration is correctly implemented, but I couldn't help but notice there's no test coverage for the new filtering functionality.

Let's check if there are any test files for this viewset:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test files related to facility viewsets
fd -g "*test*facility*.py" -g "*test*user*.py"

Length of output: 150


Script:

#!/bin/bash
# Search for test files with correct fd syntax
fd -e py -g "*test*" | grep -iE 'facility|user'

# Search for test cases related to FacilityUserFilter
rg -l "class.*Test.*Facility.*User|FacilityUserFilter" -g "*.py"

# Search for actual filter test implementations
rg "def test.*facility.*user.*filter" -g "*.py" -i

# Find the filter class definition to understand what's being tested
ast-grep --pattern 'class FacilityUserFilter'

Length of output: 819


def get_queryset(self):
return User.objects.filter(
Expand Down
Loading