@@ -298,24 +298,21 @@ def rank(self):
298
298
self .assertEqual (Person .objects .get (name = "Fred" ).rank , "Private" )
299
299
300
300
def test_db_field_conflict (self ):
301
- """Ensure we load data correctly from the right db field ."""
301
+ """Ensure two db field will not conflict ."""
302
302
303
303
class Person (Document ):
304
304
name = StringField (required = True )
305
305
age = IntField (required = False , db_field = "gregorian_age" )
306
306
lunar_age = IntField (required = False , db_field = "age" )
307
- # in 0.18.2 version, remove db_field this will run correct
308
- # age = IntField(required=False)
309
- # lunar_age = IntField(required=False)
310
307
311
308
Person .drop_collection ()
312
309
p = Person (name = "Jack" , age = "18" , lunar_age = "20" )
313
310
314
311
self .assertEqual (p ._data , {'age' : 18 , 'id' : None , 'name' : u'Jack' , 'lunar_age' : 20 })
315
312
self .assertEqual (p .to_mongo (), bson .SON ([('name' , u'Jack' ), ('gregorian_age' , 18 ), ('age' , 20 )]))
316
313
317
-
318
314
Person (name = "Jack" , age = "18" , lunar_age = "20" ).save ()
315
+
319
316
Person (name = "Fred" , age = "28" , lunar_age = "30" ).save ()
320
317
321
318
p = Person .objects .get (name = "Jack" )
@@ -376,7 +373,6 @@ class User(Document):
376
373
meta = {"allow_inheritance" : True }
377
374
378
375
with self .assertRaises (ValueError ) as e :
379
-
380
376
class EmailUser (User ):
381
377
email = StringField (primary_key = True )
382
378
@@ -775,8 +771,8 @@ class Doc(Document):
775
771
776
772
d = (
777
773
Doc (embedded_field = [Embedded (string = "Hi" )])
778
- .to_mongo (use_db_field = False )
779
- .to_dict ()
774
+ .to_mongo (use_db_field = False )
775
+ .to_dict ()
780
776
)
781
777
self .assertEqual (d ["embedded_field" ], [{"string" : "Hi" }])
782
778
@@ -1640,7 +1636,7 @@ class User(self.Person):
1640
1636
self .assertEqual (person .active , False )
1641
1637
1642
1638
def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_embedded_doc (
1643
- self
1639
+ self
1644
1640
):
1645
1641
# Refers to Issue #1685
1646
1642
class EmbeddedChildModel (EmbeddedDocument ):
@@ -1654,7 +1650,7 @@ class ParentModel(Document):
1654
1650
self .assertEqual (changed_fields , [])
1655
1651
1656
1652
def test__get_changed_fields_same_ids_reference_field_does_not_enters_infinite_loop_different_doc (
1657
- self
1653
+ self
1658
1654
):
1659
1655
# Refers to Issue #1685
1660
1656
class User (Document ):
@@ -2133,7 +2129,6 @@ def test_duplicate_db_fields_raise_invalid_document_error(self):
2133
2129
declare the same db_field.
2134
2130
"""
2135
2131
with self .assertRaises (InvalidDocumentError ):
2136
-
2137
2132
class Foo (Document ):
2138
2133
name = StringField ()
2139
2134
name2 = StringField (db_field = "name" )
@@ -2419,7 +2414,6 @@ class Foo(Document):
2419
2414
2420
2415
def test_invalid_reverse_delete_rule_raise_errors (self ):
2421
2416
with self .assertRaises (InvalidDocumentError ):
2422
-
2423
2417
class Blog (Document ):
2424
2418
content = StringField ()
2425
2419
authors = MapField (
@@ -2430,7 +2424,6 @@ class Blog(Document):
2430
2424
)
2431
2425
2432
2426
with self .assertRaises (InvalidDocumentError ):
2433
-
2434
2427
class Parents (EmbeddedDocument ):
2435
2428
father = ReferenceField ("Person" , reverse_delete_rule = DENY )
2436
2429
mother = ReferenceField ("Person" , reverse_delete_rule = DENY )
@@ -2668,7 +2661,6 @@ def test_override_method_with_field(self):
2668
2661
the "validate" method.
2669
2662
"""
2670
2663
with self .assertRaises (InvalidDocumentError ):
2671
-
2672
2664
class Blog (Document ):
2673
2665
validate = DictField ()
2674
2666
@@ -2932,8 +2924,8 @@ def __str__(self):
2932
2924
[
2933
2925
str (b )
2934
2926
for b in Book .objects .filter (
2935
- Q (extra__a = bob ) | Q (author = bob ) | Q (extra__b = bob )
2936
- )
2927
+ Q (extra__a = bob ) | Q (author = bob ) | Q (extra__b = bob )
2928
+ )
2937
2929
]
2938
2930
),
2939
2931
"1,2,3,4" ,
@@ -2945,10 +2937,10 @@ def __str__(self):
2945
2937
[
2946
2938
str (b )
2947
2939
for b in Book .objects .filter (
2948
- Q (extra__a__all = [karl , susan ])
2949
- | Q (author__all = [karl , susan ])
2950
- | Q (extra__b__all = [karl .to_dbref (), susan .to_dbref ()])
2951
- )
2940
+ Q (extra__a__all = [karl , susan ])
2941
+ | Q (author__all = [karl , susan ])
2942
+ | Q (extra__b__all = [karl .to_dbref (), susan .to_dbref ()])
2943
+ )
2952
2944
]
2953
2945
),
2954
2946
"1" ,
@@ -2960,13 +2952,13 @@ def __str__(self):
2960
2952
[
2961
2953
str (b )
2962
2954
for b in Book .objects .filter (
2963
- __raw__ = {
2964
- "$where" : """
2955
+ __raw__ = {
2956
+ "$where" : """
2965
2957
function(){
2966
2958
return this.name == '1' ||
2967
2959
this.name == '2';}"""
2968
- }
2969
- )
2960
+ }
2961
+ )
2970
2962
]
2971
2963
),
2972
2964
"1,2" ,
0 commit comments