Skip to content

Commit

Permalink
fest(sql): Refactor read handler (#2831)
Browse files Browse the repository at this point in the history
### Changed

- Refactor read handler to CRUD
  • Loading branch information
henrikstranneheim authored Jan 16, 2024
1 parent d49cde0 commit f381284
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cg/cli/workflow/mutant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@click.group(invoke_without_command=True)
@click.pass_context
def mutant(context: click.Context) -> None:
"""Covid analysis workflow"""
"""Mutant analysis workflow"""
AnalysisAPI.get_help(context)
context.obj.meta_apis["analysis_api"] = MutantAnalysisAPI(
config=context.obj,
Expand Down
6 changes: 3 additions & 3 deletions cg/store/api/core.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

from cg.store.api.find_basic_data import FindBasicDataHandler
from cg.store.api.find_business_data import FindBusinessDataHandler
from cg.store.api.status import StatusHandler
from cg.store.crud.create import CreateHandler
from cg.store.crud.delete import DeleteDataHandler
from cg.store.crud.read import ReadHandler
from cg.store.crud.update import UpdateHandler
from cg.store.database import get_session

Expand All @@ -15,7 +15,7 @@ class CoreHandler(
CreateHandler,
DeleteDataHandler,
FindBasicDataHandler,
FindBusinessDataHandler,
ReadHandler,
StatusHandler,
UpdateHandler,
):
Expand All @@ -24,7 +24,7 @@ class CoreHandler(
def __init__(self, session):
DeleteDataHandler(session)
FindBasicDataHandler(session)
FindBusinessDataHandler(session)
ReadHandler(session)
StatusHandler(session)
UpdateHandler(session)

Expand Down
6 changes: 3 additions & 3 deletions cg/store/api/find_business_data.py → cg/store/crud/read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Handler to find business data objects."""
"""Handler to read data objects."""
import datetime as dt
import logging
from typing import Callable, Iterator
Expand Down Expand Up @@ -54,8 +54,8 @@
LOG = logging.getLogger(__name__)


class FindBusinessDataHandler(BaseHandler):
"""Contains methods to find business data model instances."""
class ReadHandler(BaseHandler):
"""Class for reading items in the database."""

def __init__(self, session: Session):
super().__init__(session=session)
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/workflow/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from cg.constants import DataDelivery, FlowCellStatus, Pipeline
from cg.models.cg_config import CGConfig
from cg.store import Store
from cg.store.api.find_business_data import FindBusinessDataHandler
from cg.store.crud.read import ReadHandler
from cg.store.models import Case
from tests.store_helpers import StoreHelpers

Expand Down Expand Up @@ -239,5 +239,5 @@ def mock_analysis_flow_cell(mocker) -> None:
on disk."""
flow_cell = Mock()
flow_cell.status = FlowCellStatus.ON_DISK
mocker.patch.object(FindBusinessDataHandler, "get_flow_cells_by_case")
FindBusinessDataHandler.get_flow_cells_by_case.return_value = [flow_cell]
mocker.patch.object(ReadHandler, "get_flow_cells_by_case")
ReadHandler.get_flow_cells_by_case.return_value = [flow_cell]
6 changes: 3 additions & 3 deletions tests/cli/workflow/mip/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from cg.meta.workflow.mip_rna import MipRNAAnalysisAPI
from cg.meta.workflow.prepare_fastq import PrepareFastqAPI
from cg.models.cg_config import CGConfig
from cg.store.api.find_business_data import FindBusinessDataHandler
from cg.store.api.status import StatusHandler
from cg.store.crud.read import ReadHandler
from cg.store.models import Case
from tests.store_helpers import StoreHelpers

Expand Down Expand Up @@ -197,5 +197,5 @@ def setup_mocks(
return_value=["a str"],
)

mocker.patch.object(FindBusinessDataHandler, "are_all_flow_cells_on_disk")
FindBusinessDataHandler.are_all_flow_cells_on_disk.return_value = True
mocker.patch.object(ReadHandler, "are_all_flow_cells_on_disk")
ReadHandler.are_all_flow_cells_on_disk.return_value = True

0 comments on commit f381284

Please sign in to comment.