44from .models import Tag
55
66
7- class QueriesFilterByObjectId (TestCase ):
7+ class ObjectIdTests (TestCase ):
88 @classmethod
99 def setUpTestData (cls ):
1010 cls .group_id_str_1 = "1" * 24
@@ -19,72 +19,72 @@ def setUpTestData(cls):
1919 cls .t5 = Tag .objects .create (name = "t5" , parent = cls .t3 )
2020
2121 def test_filter_group_id_is_null_false (self ):
22- """Filter objects where group_id is not null"""
22+ """Filter objects where group_id is not null. """
2323 qs = Tag .objects .filter (group_id__isnull = False ).order_by ("name" )
2424 self .assertSequenceEqual (qs , [self .t3 , self .t4 ])
2525
2626 def test_filter_group_id_is_null_true (self ):
27- """Filter objects where group_id is null"""
27+ """Filter objects where group_id is null. """
2828 qs = Tag .objects .filter (group_id__isnull = True ).order_by ("name" )
2929 self .assertSequenceEqual (qs , [self .t1 , self .t2 , self .t5 ])
3030
3131 def test_filter_group_id_equal_str (self ):
32- """Filter by group_id with a specific string value"""
32+ """Filter by group_id with a specific string value. """
3333 qs = Tag .objects .filter (group_id = self .group_id_str_1 ).order_by ("name" )
3434 self .assertSequenceEqual (qs , [self .t3 ])
3535
3636 def test_filter_group_id_equal_obj (self ):
37- """Filter by group_id with a specific ObjectId value"""
37+ """Filter by group_id with a specific ObjectId value. """
3838 qs = Tag .objects .filter (group_id = self .group_id_obj_1 ).order_by ("name" )
3939 self .assertSequenceEqual (qs , [self .t3 ])
4040
4141 def test_filter_group_id_in_str_values (self ):
42- """Filter by group_id with string values in a list"""
42+ """Filter by group_id with string values in a list. """
4343 qs = Tag .objects .filter (group_id__in = [self .group_id_str_1 , self .group_id_str_2 ]).order_by (
4444 "name"
4545 )
4646 self .assertSequenceEqual (qs , [self .t3 , self .t4 ])
4747
4848 def test_filter_group_id_in_obj_values (self ):
49- """Filter by group_id with ObjectId values in a list"""
49+ """Filter by group_id with ObjectId values in a list. """
5050 qs = Tag .objects .filter (group_id__in = [self .group_id_obj_1 , self .group_id_obj_2 ]).order_by (
5151 "name"
5252 )
5353 self .assertSequenceEqual (qs , [self .t3 , self .t4 ])
5454
5555 def test_filter_group_id_equal_subquery (self ):
56- """Filter by group_id using a subquery"""
56+ """Filter by group_id using a subquery. """
5757 subquery = Tag .objects .filter (name = "t3" ).values ("group_id" )
5858 qs = Tag .objects .filter (group_id__in = subquery ).order_by ("name" )
5959 self .assertSequenceEqual (qs , [self .t3 ])
6060
6161 def test_filter_group_id_in_subquery (self ):
62- """Filter by group_id using a subquery with multiple values"""
62+ """Filter by group_id using a subquery with multiple values. """
6363 subquery = Tag .objects .filter (name__in = ["t3" , "t4" ]).values ("group_id" )
6464 qs = Tag .objects .filter (group_id__in = subquery ).order_by ("name" )
6565 self .assertSequenceEqual (qs , [self .t3 , self .t4 ])
6666
6767 def test_filter_parent_by_children_values_str (self ):
68- """Query to select parents of children with specific string group_id"""
68+ """Query to select parents of children with specific string group_id. """
6969 child_ids = Tag .objects .filter (group_id = self .group_id_str_1 ).values_list ("id" , flat = True )
7070 parent_qs = Tag .objects .filter (children__id__in = child_ids ).distinct ().order_by ("name" )
7171 self .assertSequenceEqual (parent_qs , [self .t1 ])
7272
7373 def test_filter_parent_by_children_values_obj (self ):
74- """Query to select parents of children with specific ObjectId group_id"""
74+ """Query to select parents of children with specific ObjectId group_id. """
7575 child_ids = Tag .objects .filter (group_id = self .group_id_obj_1 ).values_list ("id" , flat = True )
7676 parent_qs = Tag .objects .filter (children__id__in = child_ids ).distinct ().order_by ("name" )
7777 self .assertSequenceEqual (parent_qs , [self .t1 ])
7878
7979 def test_filter_group_id_union_with_str (self ):
80- """Combine queries using union with string values"""
80+ """Combine queries using union with string values. """
8181 qs_a = Tag .objects .filter (group_id = self .group_id_str_1 )
8282 qs_b = Tag .objects .filter (group_id = self .group_id_str_2 )
8383 union_qs = qs_a .union (qs_b ).order_by ("name" )
8484 self .assertSequenceEqual (union_qs , [self .t3 , self .t4 ])
8585
8686 def test_filter_group_id_union_with_obj (self ):
87- """Combine queries using union with ObjectId values"""
87+ """Combine queries using union with ObjectId values. """
8888 qs_a = Tag .objects .filter (group_id = self .group_id_obj_1 )
8989 qs_b = Tag .objects .filter (group_id = self .group_id_obj_2 )
9090 union_qs = qs_a .union (qs_b ).order_by ("name" )
0 commit comments