Skip to content

Commit

Permalink
code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbenav committed Dec 23, 2024
1 parent 044c2ed commit 9e2fa06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions tests/sqlalchemy/core/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def load_dialect_impl(self, dialect):
return dialect.type_descriptor(String(36))

def process_bind_param(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
elif dialect.name == "postgresql":
elif dialect.name == "postgresql": # pragma: no cover
return value
else:
return str(value)

def process_result_value(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
if not isinstance(value, UUID):
return UUID(value)
return value
return value # pragma: no cover


class UUIDModel(Base):
Expand All @@ -63,12 +63,12 @@ def __init__(self):
self.__visit_name__ = "uuid"

def process_bind_param(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
return str(value)

def process_result_value(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
return UUID(value)

Expand Down Expand Up @@ -155,12 +155,12 @@ async def test_custom_uuid_crud(uuid_client):
data = response.json()
assert "id" in data, f"Response does not contain 'id': {data}"
uuid_id = data["id"]
except Exception as e:
except Exception as e: # pragma: no cover
pytest.fail(f"Failed to process response: {response.text}. Error: {str(e)}")

try:
UUID(uuid_id)
except ValueError:
except ValueError: # pragma: no cover
pytest.fail("Invalid UUID format")

response = uuid_client.get(f"/custom-uuid-test/get/{uuid_id}")
Expand Down Expand Up @@ -200,5 +200,5 @@ async def test_uuid_list_endpoint(uuid_client):
for item in data:
try:
UUID(item["id"])
except ValueError:
except ValueError: # pragma: no cover
pytest.fail("Invalid UUID format in list response")
20 changes: 10 additions & 10 deletions tests/sqlmodel/core/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ def __init__(self):
super().__init__(36)

def load_dialect_impl(self, dialect):
if dialect.name == "postgresql":
if dialect.name == "postgresql": # pragma: no cover
return dialect.type_descriptor(PostgresUUID(as_uuid=True))
else:
return dialect.type_descriptor(String(36))

def process_bind_param(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
elif dialect.name == "postgresql":
elif dialect.name == "postgresql": # pragma: no cover
return value
else:
return str(value)

def process_result_value(self, value, dialect):
if value is None:
return value
return value # pragma: no cover
if not isinstance(value, UUID):
return UUID(value)
return value
return value # pragma: no cover


class UUIDModel(SQLModel, table=True):
Expand All @@ -64,12 +64,12 @@ def __init__(self):
self.__visit_name__ = "uuid"

def process_bind_param(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
return str(value)

def process_result_value(self, value, dialect):
if value is None:
if value is None: # pragma: no cover
return value
return UUID(value)

Expand Down Expand Up @@ -158,12 +158,12 @@ async def test_custom_uuid_crud(uuid_client):
data = response.json()
assert "id" in data, f"Response does not contain 'id': {data}"
uuid_id = data["id"]
except Exception as e:
except Exception as e: # pragma: no cover
pytest.fail(f"Failed to process response: {response.text}. Error: {str(e)}")

try:
UUID(uuid_id)
except ValueError:
except ValueError: # pragma: no cover
pytest.fail("Invalid UUID format")

response = uuid_client.get(f"/custom-uuid-test/get/{uuid_id}")
Expand Down Expand Up @@ -202,5 +202,5 @@ async def test_uuid_list_endpoint(uuid_client):
for item in data:
try:
UUID(item["id"])
except ValueError:
except ValueError: # pragma: no cover
pytest.fail("Invalid UUID format in list response")

0 comments on commit 9e2fa06

Please sign in to comment.