mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
@@ -59,7 +59,7 @@ class RawQueryTests(TestCase):
|
||||
self.assertTrue(hasattr(result, annotation))
|
||||
self.assertEqual(getattr(result, annotation), value)
|
||||
|
||||
def testSimpleRawQuery(self):
|
||||
def test_simple_raw_query(self):
|
||||
"""
|
||||
Basic test of raw query with a simple database query
|
||||
"""
|
||||
@@ -67,7 +67,7 @@ class RawQueryTests(TestCase):
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors)
|
||||
|
||||
def testRawQueryLazy(self):
|
||||
def test_raw_query_lazy(self):
|
||||
"""
|
||||
Raw queries are lazy: they aren't actually executed until they're
|
||||
iterated over.
|
||||
@@ -77,7 +77,7 @@ class RawQueryTests(TestCase):
|
||||
list(q)
|
||||
self.assertTrue(q.query.cursor is not None)
|
||||
|
||||
def testFkeyRawQuery(self):
|
||||
def test_FK_raw_query(self):
|
||||
"""
|
||||
Test of a simple raw query against a model containing a foreign key
|
||||
"""
|
||||
@@ -85,7 +85,7 @@ class RawQueryTests(TestCase):
|
||||
books = Book.objects.all()
|
||||
self.assertSuccessfulRawQuery(Book, query, books)
|
||||
|
||||
def testDBColumnHandler(self):
|
||||
def test_db_column_handler(self):
|
||||
"""
|
||||
Test of a simple raw query against a model containing a field with
|
||||
db_column defined.
|
||||
@@ -94,7 +94,7 @@ class RawQueryTests(TestCase):
|
||||
coffees = Coffee.objects.all()
|
||||
self.assertSuccessfulRawQuery(Coffee, query, coffees)
|
||||
|
||||
def testOrderHandler(self):
|
||||
def test_order_handler(self):
|
||||
"""
|
||||
Test of raw raw query's tolerance for columns being returned in any
|
||||
order
|
||||
@@ -110,7 +110,7 @@ class RawQueryTests(TestCase):
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors)
|
||||
|
||||
def testTranslations(self):
|
||||
def test_translations(self):
|
||||
"""
|
||||
Test of raw query's optional ability to translate unexpected result
|
||||
column names to specific model fields
|
||||
@@ -120,7 +120,7 @@ class RawQueryTests(TestCase):
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors, translations=translations)
|
||||
|
||||
def testParams(self):
|
||||
def test_params(self):
|
||||
"""
|
||||
Test passing optional query parameters
|
||||
"""
|
||||
@@ -135,7 +135,7 @@ class RawQueryTests(TestCase):
|
||||
self.assertIsInstance(repr(qset), str)
|
||||
|
||||
@skipUnlessDBFeature('supports_paramstyle_pyformat')
|
||||
def testPyformatParams(self):
|
||||
def test_pyformat_params(self):
|
||||
"""
|
||||
Test passing optional query parameters
|
||||
"""
|
||||
@@ -149,7 +149,7 @@ class RawQueryTests(TestCase):
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertIsInstance(repr(qset), str)
|
||||
|
||||
def testManyToMany(self):
|
||||
def test_many_to_many(self):
|
||||
"""
|
||||
Test of a simple raw query against a model containing a m2m field
|
||||
"""
|
||||
@@ -157,7 +157,7 @@ class RawQueryTests(TestCase):
|
||||
reviewers = Reviewer.objects.all()
|
||||
self.assertSuccessfulRawQuery(Reviewer, query, reviewers)
|
||||
|
||||
def testExtraConversions(self):
|
||||
def test_extra_conversions(self):
|
||||
"""
|
||||
Test to insure that extra translations are ignored.
|
||||
"""
|
||||
@@ -166,14 +166,14 @@ class RawQueryTests(TestCase):
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors, translations=translations)
|
||||
|
||||
def testMissingFields(self):
|
||||
def test_missing_fields(self):
|
||||
query = "SELECT id, first_name, dob FROM raw_query_author"
|
||||
for author in Author.objects.raw(query):
|
||||
self.assertNotEqual(author.first_name, None)
|
||||
# last_name isn't given, but it will be retrieved on demand
|
||||
self.assertNotEqual(author.last_name, None)
|
||||
|
||||
def testMissingFieldsWithoutPK(self):
|
||||
def test_missing_fields_without_PK(self):
|
||||
query = "SELECT first_name, dob FROM raw_query_author"
|
||||
try:
|
||||
list(Author.objects.raw(query))
|
||||
@@ -181,7 +181,7 @@ class RawQueryTests(TestCase):
|
||||
except InvalidQuery:
|
||||
pass
|
||||
|
||||
def testAnnotations(self):
|
||||
def test_annotations(self):
|
||||
query = "SELECT a.*, count(b.id) as book_count FROM raw_query_author a LEFT JOIN raw_query_book b ON a.id = b.author_id GROUP BY a.id, a.first_name, a.last_name, a.dob ORDER BY a.id"
|
||||
expected_annotations = (
|
||||
('book_count', 3),
|
||||
@@ -192,12 +192,12 @@ class RawQueryTests(TestCase):
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
|
||||
|
||||
def testWhiteSpaceQuery(self):
|
||||
def test_white_space_query(self):
|
||||
query = " SELECT * FROM raw_query_author"
|
||||
authors = Author.objects.all()
|
||||
self.assertSuccessfulRawQuery(Author, query, authors)
|
||||
|
||||
def testMultipleIterations(self):
|
||||
def test_multiple_iterations(self):
|
||||
query = "SELECT * FROM raw_query_author"
|
||||
normal_authors = Author.objects.all()
|
||||
raw_authors = Author.objects.raw(query)
|
||||
@@ -216,7 +216,7 @@ class RawQueryTests(TestCase):
|
||||
|
||||
self.assertEqual(first_iterations, second_iterations)
|
||||
|
||||
def testGetItem(self):
|
||||
def test_get_item(self):
|
||||
# Indexing on RawQuerySets
|
||||
query = "SELECT * FROM raw_query_author ORDER BY id ASC"
|
||||
third_author = Author.objects.raw(query)[2]
|
||||
|
||||
Reference in New Issue
Block a user