From 03b6f5cb87fe567066e71550f6ce9a46ec6e9662 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Wed, 22 Nov 2023 09:38:43 +0100 Subject: [PATCH] Split bulk_api/core into exceptions and helpers modules --- h/services/bulk_api/__init__.py | 2 +- h/services/bulk_api/{core.py => _helpers.py} | 4 +--- h/services/bulk_api/annotation.py | 2 +- h/services/bulk_api/exceptions.py | 2 ++ h/services/bulk_api/group.py | 2 +- .../h/services/bulk_api/{core_test.py => _helpers_test.py} | 3 ++- tests/unit/h/views/api/bulk/annotation_test.py | 2 +- tests/unit/h/views/api/bulk/group_test.py | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) rename h/services/bulk_api/{core.py => _helpers.py} (92%) create mode 100644 h/services/bulk_api/exceptions.py rename tests/unit/h/services/bulk_api/{core_test.py => _helpers_test.py} (93%) diff --git a/h/services/bulk_api/__init__.py b/h/services/bulk_api/__init__.py index 133ce18a0cc..e06cabbadf4 100644 --- a/h/services/bulk_api/__init__.py +++ b/h/services/bulk_api/__init__.py @@ -1,3 +1,3 @@ from h.services.bulk_api.annotation import BulkAnnotation, BulkAnnotationService -from h.services.bulk_api.core import BadDateFilter +from h.services.bulk_api.exceptions import BadDateFilter from h.services.bulk_api.group import BulkGroupService diff --git a/h/services/bulk_api/core.py b/h/services/bulk_api/_helpers.py similarity index 92% rename from h/services/bulk_api/core.py rename to h/services/bulk_api/_helpers.py index 08a24c5c0c9..d77292c0e97 100644 --- a/h/services/bulk_api/core.py +++ b/h/services/bulk_api/_helpers.py @@ -1,8 +1,6 @@ import sqlalchemy as sa - -class BadDateFilter(Exception): - """There is something wrong with the date filter provided.""" +from h.services.bulk_api.exceptions import BadDateFilter def date_match(column: sa.Column, spec: dict): diff --git a/h/services/bulk_api/annotation.py b/h/services/bulk_api/annotation.py index 1e838d5d1b9..08e230ca248 100644 --- a/h/services/bulk_api/annotation.py +++ b/h/services/bulk_api/annotation.py @@ -6,7 +6,7 @@ from sqlalchemy.sql import Select from h.models import AnnotationMetadata, AnnotationSlim, Group, GroupMembership, User -from h.services.bulk_api.core import date_match +from h.services.bulk_api._helpers import date_match @dataclass diff --git a/h/services/bulk_api/exceptions.py b/h/services/bulk_api/exceptions.py new file mode 100644 index 00000000000..da176582e90 --- /dev/null +++ b/h/services/bulk_api/exceptions.py @@ -0,0 +1,2 @@ +class BadDateFilter(Exception): + """There is something wrong with the date filter provided.""" diff --git a/h/services/bulk_api/group.py b/h/services/bulk_api/group.py index e9cca100b8c..219c191c6f2 100644 --- a/h/services/bulk_api/group.py +++ b/h/services/bulk_api/group.py @@ -5,7 +5,7 @@ from sqlalchemy.orm import Session from h.models import Annotation, Group -from h.services.bulk_api.core import date_match +from h.services.bulk_api._helpers import date_match @dataclass diff --git a/tests/unit/h/services/bulk_api/core_test.py b/tests/unit/h/services/bulk_api/_helpers_test.py similarity index 93% rename from tests/unit/h/services/bulk_api/core_test.py rename to tests/unit/h/services/bulk_api/_helpers_test.py index ed96e2cc972..0f359401e72 100644 --- a/tests/unit/h/services/bulk_api/core_test.py +++ b/tests/unit/h/services/bulk_api/_helpers_test.py @@ -6,7 +6,8 @@ from sqlalchemy import select from h.models import Annotation -from h.services.bulk_api.core import BadDateFilter, date_match +from h.services.bulk_api._helpers import date_match +from h.services.bulk_api.exceptions import BadDateFilter class TestDateMatch: diff --git a/tests/unit/h/views/api/bulk/annotation_test.py b/tests/unit/h/views/api/bulk/annotation_test.py index 51735175243..eb177d1b287 100644 --- a/tests/unit/h/views/api/bulk/annotation_test.py +++ b/tests/unit/h/views/api/bulk/annotation_test.py @@ -3,7 +3,7 @@ from h.schemas import ValidationError from h.services.bulk_api.annotation import BulkAnnotation -from h.services.bulk_api.core import BadDateFilter +from h.services.bulk_api.exceptions import BadDateFilter from h.views.api.bulk.annotation import BulkAnnotationSchema, bulk_annotation diff --git a/tests/unit/h/views/api/bulk/group_test.py b/tests/unit/h/views/api/bulk/group_test.py index 882853fcee2..8ca81b50d08 100644 --- a/tests/unit/h/views/api/bulk/group_test.py +++ b/tests/unit/h/views/api/bulk/group_test.py @@ -2,7 +2,7 @@ from h_matchers import Any from h.schemas import ValidationError -from h.services.bulk_api.core import BadDateFilter +from h.services.bulk_api.exceptions import BadDateFilter from h.services.bulk_api.group import BulkGroup from h.views.api.bulk.group import BulkGroupSchema, bulk_group