Skip to content

Commit f1bf044

Browse files
committed
fixes tests
1 parent 51615a1 commit f1bf044

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

packages/postgres-database/src/simcore_postgres_database/errors.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
""" aiopg errors
1+
"""aiopg errors
22
3-
StandardError
4-
|__ Warning
5-
|__ Error
6-
|__ InterfaceError
7-
|__ DatabaseError
8-
|__ DataError
9-
|__ OperationalError
10-
|__ IntegrityError
11-
|__ InternalError
12-
|__ ProgrammingError
13-
|__ NotSupportedError
3+
StandardError
4+
|__ Warning
5+
|__ Error
6+
|__ InterfaceError
7+
|__ DatabaseError
8+
|__ DataError
9+
|__ OperationalError
10+
|__ IntegrityError
11+
|__ InternalError
12+
|__ ProgrammingError
13+
|__ NotSupportedError
1414
15-
- aiopg reuses DBAPI exceptions
16-
SEE https://aiopg.readthedocs.io/en/stable/core.html?highlight=Exception#exceptions
17-
SEE http://initd.org/psycopg/docs/module.html#dbapi-exceptions
18-
SEE https://www.postgresql.org/docs/current/errcodes-appendix.html
15+
- aiopg reuses DBAPI exceptions
16+
SEE https://aiopg.readthedocs.io/en/stable/core.html?highlight=Exception#exceptions
17+
SEE http://initd.org/psycopg/docs/module.html#dbapi-exceptions
18+
SEE https://www.postgresql.org/docs/current/errcodes-appendix.html
1919
"""
20+
2021
# NOTE: psycopg2.errors are created dynamically
2122
# pylint: disable=no-name-in-module
22-
from psycopg2 import DatabaseError, DataError
23+
from psycopg2 import (
24+
DatabaseError,
25+
DataError,
26+
)
2327
from psycopg2 import Error as DBAPIError
2428
from psycopg2 import (
2529
IntegrityError,

packages/postgres-database/tests/test_models_products_prices.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import pytest
1010
import sqlalchemy as sa
11+
from asyncpg.exceptions import CheckViolationError, ForeignKeyViolationError
1112
from faker import Faker
1213
from pytest_simcore.helpers.faker_factories import random_product
13-
from simcore_postgres_database.errors import CheckViolation, ForeignKeyViolation
1414
from simcore_postgres_database.models.products import products
1515
from simcore_postgres_database.models.products_prices import products_prices
1616
from simcore_postgres_database.utils_products_prices import (
@@ -62,7 +62,7 @@ async def test_non_negative_price_not_allowed(
6262
connection: AsyncConnection, fake_product: Row, faker: Faker
6363
):
6464
# negative price not allowed
65-
with pytest.raises(CheckViolation) as exc_info:
65+
with pytest.raises(CheckViolationError) as exc_info:
6666
await connection.execute(
6767
products_prices.insert().values(
6868
product_name=fake_product.name,
@@ -102,7 +102,7 @@ async def test_delete_price_constraints(
102102
)
103103

104104
# should not be able to delete a product w/o deleting price first
105-
with pytest.raises(ForeignKeyViolation) as exc_info:
105+
with pytest.raises(ForeignKeyViolationError) as exc_info:
106106
await connection.execute(products.delete())
107107

108108
assert exc_info.match("delete")

0 commit comments

Comments
 (0)