Updated pipeline and formatted code
All checks were successful
ydeng/modvcfsamples/pipeline/head This commit looks good

Pipeline now looks for correct unit test file
This commit is contained in:
Harrison Deng 2023-06-27 14:15:03 +00:00
parent 58adf3efe8
commit 8cd09bfb41
3 changed files with 24 additions and 8 deletions

2
Jenkinsfile vendored
View File

@ -9,7 +9,7 @@ pipeline {
}
stage("unit tests") {
steps {
sh returnStatus: true, script: "python -m pytest --junitxml=unit_tests.xml --cov-report xml:test_coverage.xml --cov=modvcfsamples"
sh returnStatus: true, script: "python -m pytest --junitxml=test_results.xml --cov-report xml:test_coverage.xml --cov=modvcfsamples"
xunit checksName: '', tools: [JUnit(excludesPattern: '', pattern: 'test_results.xml', stopProcessingIfError: true)]
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'test_coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 64, lineCoverageTargets: '50, 0, 0', methodCoverageTargets: '50, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}

View File

@ -1,3 +1,3 @@
from setuptools import setup
setup()
setup()

View File

@ -1,14 +1,24 @@
from modvcfsamples.sample import keep_specific_call_data, get_records_from_vcf, normalize_gt_to_length
from modvcfsamples.sample import (
keep_specific_call_data,
get_records_from_vcf,
normalize_gt_to_length,
)
import os
def test_filter_all_sample_datatypes_not_empty():
records, header = get_records_from_vcf(os.path.abspath("tests/resources/test_files_shortened.vcf"))
records, header = get_records_from_vcf(
os.path.abspath("tests/resources/test_files_shortened.vcf")
)
filter_for = ["GT"]
modified_records, header = keep_specific_call_data(records, header, *filter_for)
assert len(modified_records) == 11
def test_filter_all_sample_datatypes_filtered():
records, header = get_records_from_vcf(os.path.abspath("tests/resources/test_files_shortened.vcf"))
records, header = get_records_from_vcf(
os.path.abspath("tests/resources/test_files_shortened.vcf")
)
filter_for = ["GT"]
modified_records, header = keep_specific_call_data(records, header, *filter_for)
for modified_record in modified_records:
@ -17,14 +27,20 @@ def test_filter_all_sample_datatypes_filtered():
for key, _ in call.data.items():
assert key in filter_for
def test_normalize_gt_to_length_not_empty():
records, header = get_records_from_vcf(os.path.abspath("tests/resources/test_files_shortened_haploid.vcf"))
records, header = get_records_from_vcf(
os.path.abspath("tests/resources/test_files_shortened_haploid.vcf")
)
modified_records, _ = normalize_gt_to_length(records, header, 4)
assert len(modified_records) > 0
def test_normalize_gt_to_length_gt_normalized():
records, header = get_records_from_vcf(os.path.abspath("tests/resources/test_files_shortened_haploid.vcf"))
records, header = get_records_from_vcf(
os.path.abspath("tests/resources/test_files_shortened_haploid.vcf")
)
modified_records, _ = normalize_gt_to_length(records, header, 4)
for modified_record in modified_records:
for call in modified_record.calls:
assert len(call.data["GT"].split("|")) == 4 or "/" in call.data["GT"]
assert len(call.data["GT"].split("|")) == 4 or "/" in call.data["GT"]