test_cli.py 1.1 KB
Newer Older
1
"""Tests for the backtranslate CLI."""
Laros's avatar
Laros committed
2
3
4
5
import sys

from hashlib import md5
from io import StringIO
Laros's avatar
Laros committed
6

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
7
from fake_open import md5_check
Laros's avatar
Laros committed
8

Jeroen F.J. Laros's avatar
Jeroen F.J. Laros committed
9
from mutalyzer_backtranslate import cli
Laros's avatar
Laros committed
10
11
12


class TestParser(object):
13
    """Test the backtranslate.backtranslate module."""
Laros's avatar
Laros committed
14
15
    def setup(self):
        self._input = open('data/mhv.fa')
Laros's avatar
Laros committed
16
        self._output = StringIO()
Laros's avatar
Laros committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30

    def test_with_dna(self):
        cli.with_dna(self._input, self._output, 210, 1, 'Leu')
        assert md5_check(
            self._output.getvalue(), 'efd57489b71583751f3a7efdd70df840')

    def test_without_dna(self):
        cli.without_dna(self._output, 92, 'Asp', 'Tyr')
        assert md5_check(
            self._output.getvalue(), '35e17a7e874f11abccb3bd3054c53993')

    def test_find_stops(self):
        cli.find_stops(self._input, self._output, 210, False)
        assert md5_check(
Laros's avatar
Laros committed
31
            self._output.getvalue(), '41c105e384651201970c0b2efd3afa3e')
Laros's avatar
Laros committed
32
33
34
35

    def test_find_stops_compact(self):
        cli.find_stops(self._input, self._output, 210, True)
        assert md5_check(
Laros's avatar
Laros committed
36
            self._output.getvalue(), '67c62854f4c0972e3fbf3dcec81b6a94')