overwrite unique constraints as old are bind to table

This commit is contained in:
collerek
2020-12-15 15:23:22 +01:00
parent 48b40d5a3c
commit 6e0da072db
2 changed files with 57 additions and 47 deletions

View File

@ -92,6 +92,7 @@ def test_init_of_abstract_model():
def test_field_redefining_raises_error():
with pytest.raises(ModelDefinitionError):
class WrongField(DateFieldsModel): # pragma: no cover
class Meta(ormar.ModelMeta):
tablename = "wrongs"
@ -104,6 +105,7 @@ def test_field_redefining_raises_error():
def test_model_subclassing_non_abstract_raises_error():
with pytest.raises(ModelDefinitionError):
class WrongField2(DateFieldsModelNoSubclass): # pragma: no cover
class Meta(ormar.ModelMeta):
tablename = "wrongs"
@ -121,7 +123,7 @@ def test_params_are_inherited():
def round_date_to_seconds(
date: datetime.datetime,
date: datetime.datetime,
) -> datetime.datetime: # pragma: no cover
if date.microsecond >= 500000:
date = date + datetime.timedelta(seconds=1)
@ -163,9 +165,9 @@ async def test_fields_inherited_from_mixin():
sub2 = (
await Subject.objects.select_related("category")
.order_by("-created_date")
.exclude_fields("updated_date")
.get()
.order_by("-created_date")
.exclude_fields("updated_date")
.get()
)
assert round_date_to_seconds(sub2.created_date) == round_date_to_seconds(
sub.created_date