-
Notifications
You must be signed in to change notification settings - Fork 263
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
Fix tests that are failing after introduction of ipam factories #2691
Conversation
@@ -1401,10 +1402,17 @@ def test_color(self): | |||
|
|||
def test_search(self): | |||
params = {"q": "active"} | |||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) | |||
value = self.queryset.values_list("pk", flat=True)[0] | |||
q = Q(name__icontains="active") | Q(slug__icontains="active") | Q(content_types__model__icontains="active") |
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 assume the content-types filter is just matching the search()
implementation? We don't actually have any models at present that match this, right?
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.
It shouldn't match on anything but we can't say for sure anymore now that the test fixtures are being randomly generated by factories. This should be the same Q object that's generated by the search filter's generate_query
method but I didn't want to leverage a method in the filterset to test the filterset.
@@ -638,22 +640,40 @@ def test_mode(self): | |||
|
|||
def test_ip_addresses(self): |
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.
Are these changes fixing #2689?
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.
Here is the change I made that seems to fix the error on my end. 6ab61c3
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.
Are these changes fixing #2689?
They are. Thanks for the reminder
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) | ||
vminterface_ct = ContentType.objects.get_for_model(VMInterface) | ||
ipaddresses = list( | ||
IPAddress.objects.filter(assigned_object_id__isnull=False, assigned_object_type=vminterface_ct.pk)[:2] |
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?
IPAddress.objects.filter(assigned_object_id__isnull=False, assigned_object_type=vminterface_ct.pk)[:2] | |
IPAddress.objects.filter(assigned_object_id__isnull=False, assigned_object_type=vminterface_ct)[:2] |
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.
That works!
Closes: #2689
What's Changed
Fix some more tests that were failing that weren't identified in the original factory fixture PRs
TODO