diff --git a/harvester/db/models/__init__.py b/harvester/db/models/__init__.py index 800b9271..2c542b76 100644 --- a/harvester/db/models/__init__.py +++ b/harvester/db/models/__init__.py @@ -1,6 +1,6 @@ from sqlalchemy import text -from sqlalchemy.orm import DeclarativeBase, mapped_column from sqlalchemy.dialects.postgresql import UUID +from sqlalchemy.orm import DeclarativeBase, mapped_column class Base(DeclarativeBase): diff --git a/harvester/db/models/models.py b/harvester/db/models/models.py index dec12407..bce7ccc7 100644 --- a/harvester/db/models/models.py +++ b/harvester/db/models/models.py @@ -1,16 +1,14 @@ +import enum import os import dotenv - -from harvester.db.models import Base - -from sqlalchemy import ForeignKey, SMALLINT, create_engine -from sqlalchemy import String, DateTime, Enum -from sqlalchemy.dialects.postgresql import JSON, UUID, ARRAY +from sqlalchemy import (SMALLINT, DateTime, Enum, ForeignKey, String, + create_engine) +from sqlalchemy.dialects.postgresql import ARRAY, JSON, UUID from sqlalchemy.orm import mapped_column, sessionmaker from sqlalchemy.sql import func -import enum +from harvester.db.models import Base dotenv.load_dotenv() diff --git a/tests/db/sqlalchemy/conftest.py b/tests/db/sqlalchemy/conftest.py index 45814231..49d3af70 100644 --- a/tests/db/sqlalchemy/conftest.py +++ b/tests/db/sqlalchemy/conftest.py @@ -1,19 +1,24 @@ -import pytest +import pytest -@pytest.fixture + +@pytest.fixture def create_test_harvest_source(): return { "id": "7b295ba9-137e-4d0d-8295-3abac2849a0e", "name": "test_harvest_source", - "notification_emails": [ "something@example.com", "another@test.com" ], + "notification_emails": ["something@example.com", "another@test.com"], "organization_name": "example", "frequency": "weekly", - "config": { "test": 1, "example": True, "something": [ "a", "b" ] }, - "urls": [ "https://path_to_resource/example.json", "https://path_to_resource/another_example.json"], - "schema_validation_type": "dcatus" + "config": {"test": 1, "example": True, "something": ["a", "b"]}, + "urls": [ + "https://path_to_resource/example.json", + "https://path_to_resource/another_example.json", + ], + "schema_validation_type": "dcatus", } -@pytest.fixture + +@pytest.fixture def create_test_harvest_job(): return { "id": "c8837a2f-bd0b-4333-82f5-0b64f126da34", @@ -21,20 +26,22 @@ def create_test_harvest_job(): "status": "INACTIVE", } -@pytest.fixture + +@pytest.fixture def create_test_harvest_record(): return { "job_id": "c8837a2f-bd0b-4333-82f5-0b64f126da34", "source_id": "7b295ba9-137e-4d0d-8295-3abac2849a0e", "status": "ACTIVE", - "s3_path": "https://bucket-name.s3.region-code.amazonaws.com/key-name" + "s3_path": "https://bucket-name.s3.region-code.amazonaws.com/key-name", } + @pytest.fixture def create_test_harvest_error(): return { "job_id": "c8837a2f-bd0b-4333-82f5-0b64f126da34", "record_id": "b5195975-03db-4cf8-b373-52035f0f428f", "record_reported_id": "example", - "severity": "CRITICAL" - } \ No newline at end of file + "severity": "CRITICAL", + } diff --git a/tests/db/sqlalchemy/test_sqlalchemy.py b/tests/db/sqlalchemy/test_sqlalchemy.py index f79d495c..22442328 100644 --- a/tests/db/sqlalchemy/test_sqlalchemy.py +++ b/tests/db/sqlalchemy/test_sqlalchemy.py @@ -1,16 +1,11 @@ -from harvester.db.models import Base -from harvester.db.models.models import ( - create_sqlalchemy_engine, - create_sqlalchemy_session, -) -from harvester.db.models.models import ( - HarvestSource, - HarvestJob, - HarvestRecord, - HarvestError, -) from sqlalchemy.orm import close_all_sessions +from harvester.db.models import Base +from harvester.db.models.models import (HarvestError, HarvestJob, + HarvestRecord, HarvestSource, + create_sqlalchemy_engine, + create_sqlalchemy_session) + def test_add_tables(): engine = create_sqlalchemy_engine()