Skip to content

Commit

Permalink
cleanup of countsbuilder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Jan 21, 2025
1 parent 4ec9453 commit 1c75965
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
9 changes: 4 additions & 5 deletions cumulus_library/builders/counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ def __init__(
" and will be removed in a future version"
)
self.study_prefix = study_prefix
else:
raise errors.CountsBuilderError(
"CountsBuilder should be initiated with a valid manifest.toml"
)

def get_table_name(self, table_name: str, duration=None) -> str:
"""Convenience method for constructing table name
:param table_name: table name to add after the study prefix
:param duration: a time period reflecting the table binning strategy
"""
if not self.study_prefix:
raise errors.CountsBuilderError(
"CountsBuilder must be either initiated with a study prefix, "
"or be in a directory with a valid manifest.toml"
)
if duration:
return f"{self.study_prefix}__{table_name}_{duration}"
else:
Expand Down
15 changes: 2 additions & 13 deletions tests/test_counts_builder.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""tests for outputs of counts_builder module"""

import pathlib
from contextlib import nullcontext as does_not_raise
from unittest import mock

import pytest

from cumulus_library import StudyManifest, errors
from cumulus_library import errors
from cumulus_library.builders import counts

TEST_PREFIX = "test"
Expand Down Expand Up @@ -201,18 +200,8 @@ def test_count_wrappers(


def test_null_study_prefix():
builder = counts.CountsBuilder()
with pytest.raises(errors.CountsBuilderError):
builder.get_table_name("table") # needs study_prefix to work


def test_implicit_study_prefix():
builder = counts.CountsBuilder()
manifest = StudyManifest(pathlib.Path("./tests/test_data/study_python_valid"))

assert builder.study_prefix is None
builder.prepare_queries(manifest=manifest)
assert builder.study_prefix == "study_python_valid"
counts.CountsBuilder()


def test_write_queries(tmp_path):
Expand Down

0 comments on commit 1c75965

Please sign in to comment.