autoformat with updated black
This commit is contained in:
@@ -13,8 +13,7 @@ BIN_VALUE = "\xa9\xf3\x8d(\xd7\x03\x84\xb4k[\x0f\xe3\xa2\x19\x85p[J\xa3\xd2>\xde
|
||||
|
||||
class TestBinaryField(MongoDBTestCase):
|
||||
def test_binary_fields(self):
|
||||
"""Ensure that binary fields can be stored and retrieved.
|
||||
"""
|
||||
"""Ensure that binary fields can be stored and retrieved."""
|
||||
|
||||
class Attachment(Document):
|
||||
content_type = StringField()
|
||||
@@ -33,8 +32,7 @@ class TestBinaryField(MongoDBTestCase):
|
||||
assert BLOB == bytes(attachment_1.blob)
|
||||
|
||||
def test_validation_succeeds(self):
|
||||
"""Ensure that valid values can be assigned to binary fields.
|
||||
"""
|
||||
"""Ensure that valid values can be assigned to binary fields."""
|
||||
|
||||
class AttachmentRequired(Document):
|
||||
blob = BinaryField(required=True)
|
||||
|
||||
@@ -8,8 +8,7 @@ from tests.utils import MongoDBTestCase
|
||||
|
||||
class TestDecimalField(MongoDBTestCase):
|
||||
def test_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to decimal fields.
|
||||
"""
|
||||
"""Ensure that invalid values cannot be assigned to decimal fields."""
|
||||
|
||||
class Person(Document):
|
||||
height = DecimalField(min_value=Decimal("0.1"), max_value=Decimal("3.5"))
|
||||
|
||||
@@ -544,8 +544,7 @@ class TestField(MongoDBTestCase):
|
||||
post.validate()
|
||||
|
||||
def test_sorted_list_sorting(self):
|
||||
"""Ensure that a sorted list field properly sorts values.
|
||||
"""
|
||||
"""Ensure that a sorted list field properly sorts values."""
|
||||
|
||||
class Comment(EmbeddedDocument):
|
||||
order = IntField()
|
||||
@@ -661,8 +660,7 @@ class TestField(MongoDBTestCase):
|
||||
)
|
||||
|
||||
def test_list_field_manipulative_operators(self):
|
||||
"""Ensure that ListField works with standard list operators that manipulate the list.
|
||||
"""
|
||||
"""Ensure that ListField works with standard list operators that manipulate the list."""
|
||||
|
||||
class BlogPost(Document):
|
||||
ref = StringField()
|
||||
@@ -1372,8 +1370,7 @@ class TestField(MongoDBTestCase):
|
||||
assert bar.generic_ref == {"_ref": expected, "_cls": "Foo"}
|
||||
|
||||
def test_list_item_dereference(self):
|
||||
"""Ensure that DBRef items in ListFields are dereferenced.
|
||||
"""
|
||||
"""Ensure that DBRef items in ListFields are dereferenced."""
|
||||
|
||||
class User(Document):
|
||||
name = StringField()
|
||||
@@ -1398,8 +1395,7 @@ class TestField(MongoDBTestCase):
|
||||
assert group_obj.members[1].name == user2.name
|
||||
|
||||
def test_recursive_reference(self):
|
||||
"""Ensure that ReferenceFields can reference their own documents.
|
||||
"""
|
||||
"""Ensure that ReferenceFields can reference their own documents."""
|
||||
|
||||
class Employee(Document):
|
||||
name = StringField()
|
||||
@@ -1426,8 +1422,7 @@ class TestField(MongoDBTestCase):
|
||||
assert peter.friends == friends
|
||||
|
||||
def test_recursive_embedding(self):
|
||||
"""Ensure that EmbeddedDocumentFields can contain their own documents.
|
||||
"""
|
||||
"""Ensure that EmbeddedDocumentFields can contain their own documents."""
|
||||
|
||||
class TreeNode(EmbeddedDocument):
|
||||
name = StringField()
|
||||
@@ -1503,8 +1498,7 @@ class TestField(MongoDBTestCase):
|
||||
AbstractDoc.drop_collection()
|
||||
|
||||
def test_reference_class_with_abstract_parent(self):
|
||||
"""Ensure that a class with an abstract parent can be referenced.
|
||||
"""
|
||||
"""Ensure that a class with an abstract parent can be referenced."""
|
||||
|
||||
class Sibling(Document):
|
||||
name = StringField()
|
||||
@@ -1574,8 +1568,7 @@ class TestField(MongoDBTestCase):
|
||||
brother.save()
|
||||
|
||||
def test_generic_reference(self):
|
||||
"""Ensure that a GenericReferenceField properly dereferences items.
|
||||
"""
|
||||
"""Ensure that a GenericReferenceField properly dereferences items."""
|
||||
|
||||
class Link(Document):
|
||||
title = StringField()
|
||||
@@ -1614,8 +1607,7 @@ class TestField(MongoDBTestCase):
|
||||
assert isinstance(bm.bookmark_object, Link)
|
||||
|
||||
def test_generic_reference_list(self):
|
||||
"""Ensure that a ListField properly dereferences generic references.
|
||||
"""
|
||||
"""Ensure that a ListField properly dereferences generic references."""
|
||||
|
||||
class Link(Document):
|
||||
title = StringField()
|
||||
@@ -1718,8 +1710,7 @@ class TestField(MongoDBTestCase):
|
||||
assert bm.bookmark_object == post_1
|
||||
|
||||
def test_generic_reference_string_choices(self):
|
||||
"""Ensure that a GenericReferenceField can handle choices as strings
|
||||
"""
|
||||
"""Ensure that a GenericReferenceField can handle choices as strings"""
|
||||
|
||||
class Link(Document):
|
||||
title = StringField()
|
||||
@@ -1811,8 +1802,7 @@ class TestField(MongoDBTestCase):
|
||||
assert user.bookmarks == [post_1]
|
||||
|
||||
def test_generic_reference_list_item_modification(self):
|
||||
"""Ensure that modifications of related documents (through generic reference) don't influence on querying
|
||||
"""
|
||||
"""Ensure that modifications of related documents (through generic reference) don't influence on querying"""
|
||||
|
||||
class Post(Document):
|
||||
title = StringField()
|
||||
@@ -1900,8 +1890,7 @@ class TestField(MongoDBTestCase):
|
||||
assert doc == doc2
|
||||
|
||||
def test_choices_allow_using_sets_as_choices(self):
|
||||
"""Ensure that sets can be used when setting choices
|
||||
"""
|
||||
"""Ensure that sets can be used when setting choices"""
|
||||
|
||||
class Shirt(Document):
|
||||
size = StringField(choices={"M", "L"})
|
||||
@@ -1920,8 +1909,7 @@ class TestField(MongoDBTestCase):
|
||||
shirt.validate()
|
||||
|
||||
def test_choices_validation_accept_possible_value(self):
|
||||
"""Ensure that value is in a container of allowed values.
|
||||
"""
|
||||
"""Ensure that value is in a container of allowed values."""
|
||||
|
||||
class Shirt(Document):
|
||||
size = StringField(choices=("S", "M"))
|
||||
@@ -1930,8 +1918,7 @@ class TestField(MongoDBTestCase):
|
||||
shirt.validate()
|
||||
|
||||
def test_choices_validation_reject_unknown_value(self):
|
||||
"""Ensure that unallowed value are rejected upon validation
|
||||
"""
|
||||
"""Ensure that unallowed value are rejected upon validation"""
|
||||
|
||||
class Shirt(Document):
|
||||
size = StringField(choices=("S", "M"))
|
||||
@@ -1989,8 +1976,7 @@ class TestField(MongoDBTestCase):
|
||||
shirt1.validate()
|
||||
|
||||
def test_simple_choices_validation(self):
|
||||
"""Ensure that value is in a container of allowed values.
|
||||
"""
|
||||
"""Ensure that value is in a container of allowed values."""
|
||||
|
||||
class Shirt(Document):
|
||||
size = StringField(max_length=3, choices=("S", "M", "L", "XL", "XXL"))
|
||||
@@ -2039,8 +2025,7 @@ class TestField(MongoDBTestCase):
|
||||
shirt.validate()
|
||||
|
||||
def test_simple_choices_validation_invalid_value(self):
|
||||
"""Ensure that error messages are correct.
|
||||
"""
|
||||
"""Ensure that error messages are correct."""
|
||||
SIZES = ("S", "M", "L", "XL", "XXL")
|
||||
COLORS = (("R", "Red"), ("B", "Blue"))
|
||||
SIZE_MESSAGE = u"Value must be one of ('S', 'M', 'L', 'XL', 'XXL')"
|
||||
|
||||
@@ -48,8 +48,7 @@ class TestFileField(MongoDBTestCase):
|
||||
DemoFile.objects.create()
|
||||
|
||||
def test_file_fields(self):
|
||||
"""Ensure that file fields can be written to and their data retrieved
|
||||
"""
|
||||
"""Ensure that file fields can be written to and their data retrieved"""
|
||||
|
||||
class PutFile(Document):
|
||||
the_file = FileField()
|
||||
@@ -91,8 +90,7 @@ class TestFileField(MongoDBTestCase):
|
||||
result.the_file.delete()
|
||||
|
||||
def test_file_fields_stream(self):
|
||||
"""Ensure that file fields can be written to and their data retrieved
|
||||
"""
|
||||
"""Ensure that file fields can be written to and their data retrieved"""
|
||||
|
||||
class StreamFile(Document):
|
||||
the_file = FileField()
|
||||
@@ -228,8 +226,7 @@ class TestFileField(MongoDBTestCase):
|
||||
assert ["doc_b", "doc_e"] == grid_fs.list()
|
||||
|
||||
def test_file_uniqueness(self):
|
||||
"""Ensure that each instance of a FileField is unique
|
||||
"""
|
||||
"""Ensure that each instance of a FileField is unique"""
|
||||
|
||||
class TestFile(Document):
|
||||
name = StringField()
|
||||
@@ -285,8 +282,7 @@ class TestFileField(MongoDBTestCase):
|
||||
assert test_file.the_file.get().length == 4971
|
||||
|
||||
def test_file_boolean(self):
|
||||
"""Ensure that a boolean test of a FileField indicates its presence
|
||||
"""
|
||||
"""Ensure that a boolean test of a FileField indicates its presence"""
|
||||
|
||||
class TestFile(Document):
|
||||
the_file = FileField()
|
||||
|
||||
@@ -19,8 +19,7 @@ class TestFloatField(MongoDBTestCase):
|
||||
assert 1 == TestDocument.objects(float_fld__ne=1).count()
|
||||
|
||||
def test_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to float fields.
|
||||
"""
|
||||
"""Ensure that invalid values cannot be assigned to float fields."""
|
||||
|
||||
class Person(Document):
|
||||
height = FloatField(min_value=0.1, max_value=3.5)
|
||||
|
||||
@@ -290,8 +290,7 @@ class TestGeoField(MongoDBTestCase):
|
||||
Location(loc=[[[[1, 2], [3, 4], [5, 6], [1, 2]]]]).validate()
|
||||
|
||||
def test_indexes_geopoint(self):
|
||||
"""Ensure that indexes are created automatically for GeoPointFields.
|
||||
"""
|
||||
"""Ensure that indexes are created automatically for GeoPointFields."""
|
||||
|
||||
class Event(Document):
|
||||
title = StringField()
|
||||
@@ -317,8 +316,7 @@ class TestGeoField(MongoDBTestCase):
|
||||
assert geo_indicies == [{"fields": [("venue.location", "2d")]}]
|
||||
|
||||
def test_indexes_2dsphere(self):
|
||||
"""Ensure that indexes are created automatically for GeoPointFields.
|
||||
"""
|
||||
"""Ensure that indexes are created automatically for GeoPointFields."""
|
||||
|
||||
class Event(Document):
|
||||
title = StringField()
|
||||
@@ -332,8 +330,7 @@ class TestGeoField(MongoDBTestCase):
|
||||
assert {"fields": [("point", "2dsphere")]} in geo_indicies
|
||||
|
||||
def test_indexes_2dsphere_embedded(self):
|
||||
"""Ensure that indexes are created automatically for GeoPointFields.
|
||||
"""
|
||||
"""Ensure that indexes are created automatically for GeoPointFields."""
|
||||
|
||||
class Venue(EmbeddedDocument):
|
||||
name = StringField()
|
||||
|
||||
@@ -7,8 +7,7 @@ from tests.utils import MongoDBTestCase
|
||||
|
||||
class TestIntField(MongoDBTestCase):
|
||||
def test_int_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to int fields.
|
||||
"""
|
||||
"""Ensure that invalid values cannot be assigned to int fields."""
|
||||
|
||||
class Person(Document):
|
||||
age = IntField(min_value=0, max_value=110)
|
||||
|
||||
@@ -25,8 +25,7 @@ class TestLongField(MongoDBTestCase):
|
||||
assert isinstance(doc.some_long, int)
|
||||
|
||||
def test_long_validation(self):
|
||||
"""Ensure that invalid values cannot be assigned to long fields.
|
||||
"""
|
||||
"""Ensure that invalid values cannot be assigned to long fields."""
|
||||
|
||||
class TestDocument(Document):
|
||||
value = LongField(min_value=0, max_value=110)
|
||||
|
||||
@@ -107,8 +107,7 @@ class TestReferenceField(MongoDBTestCase):
|
||||
assert p.parent == p1
|
||||
|
||||
def test_undefined_reference(self):
|
||||
"""Ensure that ReferenceFields may reference undefined Documents.
|
||||
"""
|
||||
"""Ensure that ReferenceFields may reference undefined Documents."""
|
||||
|
||||
class Product(Document):
|
||||
name = StringField()
|
||||
|
||||
@@ -38,8 +38,7 @@ class TestURLField(MongoDBTestCase):
|
||||
)
|
||||
|
||||
def test_url_scheme_validation(self):
|
||||
"""Ensure that URLFields validate urls with specific schemes properly.
|
||||
"""
|
||||
"""Ensure that URLFields validate urls with specific schemes properly."""
|
||||
|
||||
class Link(Document):
|
||||
url = URLField()
|
||||
|
||||
@@ -17,8 +17,7 @@ class TestUUIDField(MongoDBTestCase):
|
||||
assert get_as_pymongo(person) == {"_id": person.id, "api_key": str(uid)}
|
||||
|
||||
def test_field_string(self):
|
||||
"""Test UUID fields storing as String
|
||||
"""
|
||||
"""Test UUID fields storing as String"""
|
||||
Person.drop_collection()
|
||||
|
||||
uu = uuid.uuid4()
|
||||
|
||||
Reference in New Issue
Block a user