Commit 19c938e1 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Add unit tests (fixes #38)

parent 7ecd0ccd
>seq_1.cds_10
MNNKGSGLTPAQALDKLDALYEQSVVALRNAIGNYITSGELPDENARKQGLFVYPSLTVT
WDGSTTNPPKTRAFGRFTHAGSYTTTITRPTLFRSYLNEQLTLLYQDYGAHISVQPSQHE
IPYPYVIDGSELTLDRSMSAGLTRYFPTTELAQIGDETADGIYHPTEFSPLSHFDARRVD
FSLARLRHYTGTPVEHFQPFVLFTNYTRYVDEFVRWGCSQILDPDSPYIALSCAGGNWIT
AETEAPEEAISDLAWKKNQMPAWHLITADGQGITLVNIGVGPSNAKTICDHLAVLRPDVW
LMIGHCGGLRESQAIGDYVLAHAYLRDDHVLDAVLPPDIPIPSIAEVQRALYDATKLVSG
RPGEEVKQRLRTGTVVTTDDRNWELRYSASALRFNLSRAVAIDMESATIAAQGYRFRVPY
GTLLCVSDKPLHGEIKLPGQANRFYEGAISEHLQIGIRAIDLLRAEGDRLHSRKLRTFNE
PPFR*
import unittest
from psot import config
class TestConfig(unittest.TestCase):
def test_load_config_works(self):
cfg = config.load_config()
self.assertTrue('modules' in cfg)
self.assertTrue('profiles' in cfg)
self.assertTrue('app' in cfg)
import unittest
import pkg_resources
from tempfile import mkdtemp
from shutil import rmtree
from subprocess import run
import os.path
import json
class TestPsot(unittest.TestCase):
def test_that_psot_fails_if_input_file_does_not_exist(self):
proc = run(["psot", 'analyze', '-f', 'file', '-o', 'temporary output directory', '-p', 'fast'])
self.assertNotEqual(proc.returncode, 0)
def test_that_psot_runs(self):
profiles = ['fast', 'common', 'complete']
testdata = pkg_resources.resource_filename('tests', 'data/single.fas')
for profile in profiles:
with self.subTest(profile=profile):
result_directory = mkdtemp()
proc = run(["psot", 'analyze', '-f', testdata, '-o', result_directory, '-p', profile])
# first check if the result file exists
expected_file = result_directory +'/seq_1.cds_10.json'
self.assertTrue(os.path.exists(expected_file))
# now check if it is a valid json and contains the id and a non-empty list of results
with open(expected_file, 'r') as f:
result = json.load(f)
self.assertTrue('id' in result)
self.assertTrue('computations' in result)
self.assertGreater(len(result['computations']), 0)
rmtree(result_directory)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment