Skip to content

Commit

Permalink
glamr/tests: add tests for QuerySet.iterate()
Browse files Browse the repository at this point in the history
  • Loading branch information
robert102 committed Nov 21, 2024
1 parent 74cefe1 commit a879fb7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions mibios/glamr/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,32 @@ def test_from_frontpage(self):
@tag('longrun')
class VeryDeepLinkTests(DeepLinkTests):
MAX_DEPTH = 3


class QuerySetIterateTests(TestDataMixin, TestCase):
def test_model_iterate(self):
qs = Sample.objects.all()
kw_picks = [
dict(chunk_size=1000),
dict(cache=True),
dict(cache=False),
]
for kwargs in kw_picks:
with self.subTest(iterate_kwargs=kwargs):
list(qs.iterate(**kwargs))

def test_values_list_iterate(self):
qss = {
'all_cols': Sample.objects.values_list(),
'with_pk': Sample.objects.values_list('pk', 'sample_id'),
'no_pk': Sample.objects.values_list('sample_id', 'dataset'),
}
kw_picks = [
dict(chunk_size=1000),
dict(cache=True),
dict(cache=False),
]
for qs in qss.keys():
for kwargs in kw_picks:
with self.subTest(iterate_kwargs=kwargs, queryset=qs):
list(qss[qs].iterate(**kwargs))

0 comments on commit a879fb7

Please sign in to comment.