MCPcopy
hub / github.com/django/django / test_lookup_rhs

Method test_lookup_rhs

tests/lookup/tests.py:1744–1761  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1742 )
1743
1744 def test_lookup_rhs(self):
1745 product = Product.objects.create(name="GME", qty_target=5000)
1746 stock_1 = Stock.objects.create(product=product, short=True, qty_available=180)
1747 stock_2 = Stock.objects.create(product=product, short=False, qty_available=5100)
1748 Stock.objects.create(product=product, short=False, qty_available=4000)
1749 self.assertCountEqual(
1750 Stock.objects.filter(short=Q(qty_available__lt=F("product__qty_target"))),
1751 [stock_1, stock_2],
1752 )
1753 self.assertCountEqual(
1754 Stock.objects.filter(
1755 short=ExpressionWrapper(
1756 Q(qty_available__lt=F("product__qty_target")),
1757 output_field=BooleanField(),
1758 )
1759 ),
1760 [stock_1, stock_2],
1761 )
1762
1763 def test_lookup_direct_value_rhs_unwrapped(self):
1764 with self.assertNumQueries(1) as ctx:

Callers

nothing calls this directly

Calls 6

QClass · 0.90
FClass · 0.90
ExpressionWrapperClass · 0.90
BooleanFieldClass · 0.90
createMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected