Skip to content
Snippets Groups Projects
Commit 354fcbd4 authored by Hugo Madge Leon's avatar Hugo Madge Leon
Browse files

I still don't know how this works

parent ec80b65b
No related branches found
No related tags found
1 merge request!41I still don't know how this works
Pipeline #14867 failed
......@@ -28,8 +28,7 @@ def check_positive(value: str) -> int:
def check_prob(value: str) -> float:
"""
Check probability value is within ]0,1] range.
"""Check probability value is within ]0,1] range.
Args:
value (str): command line parameter
......@@ -42,6 +41,6 @@ def check_prob(value: str) -> float:
"""
pvalue = float(value)
if pvalue <= 0 or pvalue > 1:
raise argparse.ArgumentTypeError("""%s is an invalid positive int
value""" % value)
raise argparse.ArgumentTypeError("""Expected a positive float between
0 and 1, but got {value}""")
return pvalue
"""Test cli.py functions."""
import pytest
# from Bio import SeqIO
from term_frag_sel.cli import file_validation # type: ignore
FASTA_FILE = "tests/test_files/test.fasta"
def test_file():
"""Test check_positive function."""
with pytest.raises(FileNotFoundError):
file_validation("", "", ",")
This diff is collapsed.
"""Test utils.py functions."""
import pytest
from Bio import SeqIO
from term_frag_sel.fragmentation import fragmentation # type: ignore
with open("tests/test_files/test.fasta", "r", encoding="utf-8") as handle:
fasta = SeqIO.parse(handle, "fasta")
# have to create the counts file
MU = 100
STD = 10
A_PROB = 0.22
C_PROB = 0.28
T_PROB = 0.25
G_PROB = 0.25
def test_frag():
"""Test fragmentation function."""
with pytest.raises(TypeError):
fragmentation()
"""Test utils.py functions."""
<<<<<<< HEAD
import pytest
from
=======
import argparse
import pytest
from term_frag_sel.utils import check_positive, check_prob # type: ignore
def test_positive():
"""Test check_positive function."""
assert check_positive("1") == 1
assert check_positive("100") == 100
assert check_positive("2.2") == 2
assert check_positive("2.6") == 3
with pytest.raises(argparse.ArgumentTypeError):
check_positive("0")
with pytest.raises(argparse.ArgumentTypeError):
check_positive("-1")
with pytest.raises(argparse.ArgumentTypeError):
check_positive("string")
with pytest.raises(argparse.ArgumentTypeError):
check_positive("")
def test_prob():
"""Test check_prob function."""
assert check_prob("0.1") == 0.1
assert check_prob("1") == 1.0
with pytest.raises(argparse.ArgumentTypeError):
check_prob("0")
with pytest.raises(argparse.ArgumentTypeError):
check_prob("10")
with pytest.raises(argparse.ArgumentTypeError):
check_prob("-1")
with pytest.raises(ValueError):
check_prob("string")
with pytest.raises(ValueError):
check_prob("")
>>>>>>> hugo_new
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment