MCPcopy
hub / github.com/django/django / test_params

Method test_params

tests/raw_query/tests.py:221–233  ·  view source on GitHub ↗

Test passing optional query parameters

(self)

Source from the content-addressed store, hash-verified

219 self.assertSuccessfulRawQuery(Author, query, authors, translations=translations)
220
221 def test_params(self):
222 """
223 Test passing optional query parameters
224 """
225 query = "SELECT * FROM raw_query_author WHERE first_name = %s"
226 author = Author.objects.all()[2]
227 params = [author.first_name]
228 qset = Author.objects.raw(query, params=params)
229 results = list(qset)
230 self.assertProcessed(Author, results, [author])
231 self.assertNoAnnotations(results)
232 self.assertEqual(len(results), 1)
233 self.assertIsInstance(repr(qset), str)
234
235 def test_params_none(self):
236 query = "SELECT * FROM raw_query_author WHERE first_name like 'J%'"

Callers

nothing calls this directly

Calls 4

assertProcessedMethod · 0.95
assertNoAnnotationsMethod · 0.95
allMethod · 0.45
rawMethod · 0.45

Tested by

no test coverage detected