Skip to content

Commit

Permalink
Fix renderer classes ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
hipek8 committed Nov 18, 2024
1 parent 530cac3 commit d3bb229
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/ralph/assets/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,8 @@ def test_get_dc_hosts_list(self):
VirtualServerFullFactory.create_batch(20, parent=dc_assets[0])
CloudHostFullFactory.create_batch(20, hypervisor=dc_assets[0])
url = reverse('dchost-list') + "?limit=100"
with self.assertNumQueries(31):
response = self.client.get(url, format='json')
with self.assertQueriesMoreOrLess(30, plus_minus=1):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 63)

Expand Down
11 changes: 7 additions & 4 deletions src/ralph/lib/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ def render_form_for_serializer(self, serializer):


def renderer_classes_without_form(renderer_classes):
return [OnlyRawBrowsableAPIRenderer] + [
rc for rc in renderer_classes
if not isinstance(rc(), BrowsableAPIRenderer)
]
def _gen():
for rc in renderer_classes:
if not isinstance(rc(), BrowsableAPIRenderer):
yield rc
else:
yield OnlyRawBrowsableAPIRenderer
return [rc for rc in _gen()]

0 comments on commit d3bb229

Please sign in to comment.