Skip to content

Commit

Permalink
Adding tests for samplesheets config.
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Apr 30, 2021
1 parent 8485c69 commit fd75dae
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 8 deletions.
20 changes: 12 additions & 8 deletions sodar_cli/samplesheet/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class SampleSheetRetrieveConfig:
project_uuid: uuid.UUID

@staticmethod
def create(args, project_config, toml_config=None):
def create(args, samplesheet_config, toml_config=None):
_ = toml_config
# toml_config = toml_config or {}
return SampleSheetRetrieveConfig(
project_config=project_config, project_uuid=args.project_uuid
samplesheet_config=samplesheet_config, project_uuid=args.project_uuid
)


Expand All @@ -54,10 +54,12 @@ class SampleSheetImportConfig:
file_paths: typing.List[str]

@staticmethod
def create(args, project_config, toml_config=None):
def create(args, samplesheet_config, toml_config=None):
# toml_config = toml_config or {}
return SampleSheetImportConfig(
project_config=project_config, file_paths=list(args.file_paths)
samplesheet_config=samplesheet_config,
project_uuid=args.project_uuid,
file_paths=list(args.file_paths),
)


Expand All @@ -72,10 +74,10 @@ class SampleSheetExportConfig:
project_uuid: uuid.UUID

@staticmethod
def create(args, project_config, toml_config=None):
def create(args, samplesheet_config, toml_config=None):
# toml_config = toml_config or {}
return SampleSheetExportConfig(
project_config=project_config, project_uuid=args.project_uuid
samplesheet_config=samplesheet_config, project_uuid=args.project_uuid
)


Expand All @@ -90,6 +92,8 @@ class SampleDataFileExistsConfig:
md5_sum: str

@staticmethod
def create(args, project_config, toml_config=None):
def create(args, samplesheet_config, toml_config=None):
# toml_config = toml_config or {}
return SampleDataFileExistsConfig(project_config=project_config, md5_sum=args.md5_sum)
return SampleDataFileExistsConfig(
samplesheet_config=samplesheet_config, md5_sum=args.md5_sum
)
45 changes: 45 additions & 0 deletions tests/test_samplesheet_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from types import SimpleNamespace

from sodar_cli.common import CommonConfig
from sodar_cli.samplesheet import config

import pytest


@pytest.fixture
def args():
return SimpleNamespace(
verbose=False,
verify_ssl=True,
sodar_api_token="XXX",
sodar_server_url="https://sodar.example.com/",
project_uuid="123",
file_paths=[],
md5_sum="asdf",
)


@pytest.fixture
def common_config(args):
return CommonConfig.create(args)


@pytest.fixture
def project_config(args, common_config):
return config.SampleSheetConfig.create(args, common_config)


def test_samplesheet_retrieve_config(args, common_config):
config.SampleSheetRetrieveConfig.create(args, common_config)


def test_samplesheet_import_config(args, common_config):
config.SampleSheetImportConfig.create(args, common_config)


def test_samplesheet_export_config(args, common_config):
config.SampleSheetExportConfig.create(args, common_config)


def test_sample_data_file_exists_config(args, common_config):
config.SampleDataFileExistsConfig.create(args, common_config)

0 comments on commit fd75dae

Please sign in to comment.