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

Fix tests that are failing after introduction of ipam factories #2691

Merged
merged 4 commits into from
Oct 27, 2022

Conversation

gsnider2195
Copy link
Contributor

@gsnider2195 gsnider2195 commented Oct 27, 2022

Closes: #2689

What's Changed

Fix some more tests that were failing that weren't identified in the original factory fixture PRs

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • n/a Attached Screenshots, Payload Example
  • n/a Unit, Integration Tests
  • n/a Documentation Updates (when adding/changing features)
  • n/a Example Plugin Updates (when adding/changing features)
  • n/a Outline Remaining Work, Constraints from Design

@@ -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")
Copy link
Contributor

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?

Copy link
Contributor Author

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):
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think?

Suggested change
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]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That works!

@gsnider2195 gsnider2195 linked an issue Oct 27, 2022 that may be closed by this pull request
@gsnider2195 gsnider2195 merged commit aa450f6 into next Oct 27, 2022
@gsnider2195 gsnider2195 deleted the gas-factory-tests-fix branch October 27, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Virtualization filter test failure
3 participants