ran unittest2pytest

This commit is contained in:
Bastien Gérard
2019-08-30 16:13:30 +03:00
parent aa6ff8c84a
commit ac25f4b98b
46 changed files with 4247 additions and 4428 deletions

View File

@@ -4,6 +4,7 @@ import uuid
from mongoengine import *
from tests.utils import MongoDBTestCase, get_as_pymongo
import pytest
class Person(Document):
@@ -14,9 +15,7 @@ class TestUUIDField(MongoDBTestCase):
def test_storage(self):
uid = uuid.uuid4()
person = Person(api_key=uid).save()
self.assertEqual(
get_as_pymongo(person), {"_id": person.id, "api_key": str(uid)}
)
assert get_as_pymongo(person) == {"_id": person.id, "api_key": str(uid)}
def test_field_string(self):
"""Test UUID fields storing as String
@@ -25,8 +24,8 @@ class TestUUIDField(MongoDBTestCase):
uu = uuid.uuid4()
Person(api_key=uu).save()
self.assertEqual(1, Person.objects(api_key=uu).count())
self.assertEqual(uu, Person.objects.first().api_key)
assert 1 == Person.objects(api_key=uu).count()
assert uu == Person.objects.first().api_key
person = Person()
valid = (uuid.uuid4(), uuid.uuid1())
@@ -40,7 +39,8 @@ class TestUUIDField(MongoDBTestCase):
)
for api_key in invalid:
person.api_key = api_key
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()
def test_field_binary(self):
"""Test UUID fields storing as Binary object."""
@@ -48,8 +48,8 @@ class TestUUIDField(MongoDBTestCase):
uu = uuid.uuid4()
Person(api_key=uu).save()
self.assertEqual(1, Person.objects(api_key=uu).count())
self.assertEqual(uu, Person.objects.first().api_key)
assert 1 == Person.objects(api_key=uu).count()
assert uu == Person.objects.first().api_key
person = Person()
valid = (uuid.uuid4(), uuid.uuid1())
@@ -63,4 +63,5 @@ class TestUUIDField(MongoDBTestCase):
)
for api_key in invalid:
person.api_key = api_key
self.assertRaises(ValidationError, person.validate)
with pytest.raises(ValidationError):
person.validate()