Skip to content

queryset

Utils to manage querysets.

get_pks

Get primary keys from a QuerySet.

example:

import capyc.pytest as capy
from my_app.models import MyModel

def test_something(queryset: capy.QuerySet):
    qs = MyModel.objects.filter()
    x = queryset.get_pks(qs)
    assert x == [1, 2, 3]

with_pks

Assert that a QuerySet contains the following primary keys.

example:

import capyc.pytest as capy
from my_app.models import MyModel

def test_something(queryset: capy.QuerySet):
    qs = MyModel.objects.filter()
    queryset.with_pks(qs, [1, 2, 3])