Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Added unittests for common.py #45

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/integration_tests/test_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest
from app import common
import datetime

# checking validate_subject method
def test_validate_subject():
patient_id = "HG00XXX"

with pytest.raises(Exception) as excinfo:
common.validate_subject(patient_id)

expected_msg = f"Patient ({patient_id}) not found."
assert str(excinfo.value) == f"400 Bad Request: {expected_msg}"

# checking in_int method
def test_is_int():
assert common.is_int('2') == True
assert common.is_int('string') == False
assert common.is_int('3.2') == False

# checking the date
def test_get_date():
assert common.get_date("ge2022-01-01") == {'OPERATOR': '$gte','DATE': datetime.datetime(2022,1,1)}
with pytest.raises(KeyError):
common.get_date("2022-01-01")

# checking get_build_and_chrom_by_ref_seq
def test_get_build_and_chrom_by_ref_seq():
assert common.get_build_and_chrom_by_ref_seq('NC_012920.1') == {"chrom": 'chrM', "build": 'GRCh37'}
assert common.get_build_and_chrom_by_ref_seq('NC_000014.9') == {"chrom": 'chr14', "build": 'GRCh38'}

#
def test_get_other_build():
assert common.get_other_build('GRCh38') == "GRCh37"
assert common.get_other_build('GRCh34') == "GRCh38"