From d2921167bd674e0294b6440e8cf334d8d82216bd Mon Sep 17 00:00:00 2001 From: collerek Date: Wed, 28 Apr 2021 17:16:30 +0200 Subject: [PATCH] fix coverage --- Makefile | 8 +++++++- .../test_model_definition/test_model_definition.py | 13 +++++++++++++ tests/test_model_definition/test_pydantic_fields.py | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 721821b..8dfb73b 100644 --- a/Makefile +++ b/Makefile @@ -16,4 +16,10 @@ test_mysql: docker-compose -f scripts/docker-compose.yml stop mysql test_sqlite: - bash scripts/test.sh -svv \ No newline at end of file + bash scripts/test.sh -svv + +test: + pytest + +coverage: + pytest --cov=ormar --cov=tests --cov-fail-under=100 --cov-report=term-missing \ No newline at end of file diff --git a/tests/test_model_definition/test_model_definition.py b/tests/test_model_definition/test_model_definition.py index f3cf30f..3585949 100644 --- a/tests/test_model_definition/test_model_definition.py +++ b/tests/test_model_definition/test_model_definition.py @@ -218,6 +218,19 @@ def test_decimal_error_in_model_definition(): test: decimal.Decimal = ormar.Decimal(primary_key=True) +@typing.no_type_check +def test_binary_error_without_length_model_definition(): + with pytest.raises(ModelDefinitionError): + + class ExampleModel2(Model): + class Meta: + tablename = "example6" + database = database + metadata = metadata + + test: bytes = ormar.LargeBinary(primary_key=True) + + @typing.no_type_check def test_string_error_in_model_definition(): with pytest.raises(ModelDefinitionError): diff --git a/tests/test_model_definition/test_pydantic_fields.py b/tests/test_model_definition/test_pydantic_fields.py index b4be0ae..4aae511 100644 --- a/tests/test_model_definition/test_pydantic_fields.py +++ b/tests/test_model_definition/test_pydantic_fields.py @@ -17,7 +17,7 @@ class BaseMeta(ormar.ModelMeta): database = database -class Test(ormar.Model): +class ModelTest(ormar.Model): class Meta(BaseMeta): pass @@ -44,7 +44,7 @@ def create_test_database(): @pytest.mark.asyncio async def test_working_with_pydantic_fields(): async with database: - test = Test(name="Test") + test = ModelTest(name="Test") assert test.name == "Test" assert test.url == "www.example.com" @@ -52,7 +52,7 @@ async def test_working_with_pydantic_fields(): assert test.url == "www.sdta.ada.pt" await test.save() - test_check = await Test.objects.get() + test_check = await ModelTest.objects.get() assert test_check.name == "Test" assert test_check.url == "www.example.com"