Commit b5998bc6 authored by Laros's avatar Laros
Browse files

Added tests.

parent 288e605c
"""
Tests for the barcode CLI.
"""
import Levenshtein
from barcode.cli import make_barcodes, test_barcodes as _test_barcodes
class TestCLI(object):
def setup(self):
pass #self._output = StringIO.StringIO()
def test_make_barcodes_1(self):
assert make_barcodes(2, 1, 1, Levenshtein.distance) == ['AC', 'AG',
'AT', 'CA', 'CG', 'CT', 'GA', 'GC', 'GT', 'TA', 'TC', 'TG']
def test_make_barcodes_2(self):
assert make_barcodes(3, 1, 2, Levenshtein.distance) == ['ACA', 'AGC',
'ATG', 'CAC', 'CGA', 'GAG', 'GCT', 'GTA', 'TAT', 'TCG']
def test_barcodes_1(self):
assert _test_barcodes(
['AAA', 'AAT', 'ATA'], 2, Levenshtein.distance, None) == 2
def test_barcodes_2(self):
assert _test_barcodes(
['AAA', 'AAT', 'ATC'], 2, Levenshtein.distance, None) == 1
"""
Tests for the barcode library.
"""
from barcode import all_barcodes, filter_distance, filter_stretches
class TestLibrary(object):
def test_all_barcodes_1(self):
assert all_barcodes(2) == ['AA', 'AC', 'AG', 'AT', 'CA', 'CC', 'CG',
'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TC', 'TG', 'TT']
def test_all_barcodes_2(self):
assert len(all_barcodes(3)) == 4 ** 3
def test_all_barcodes_3(self):
assert len(all_barcodes(4)) == 4 ** 4
def test_all_barcodes_3(self):
assert len(all_barcodes(5)) == 4 ** 5
def test_filter_distance_1(self):
assert filter_distance(all_barcodes(2), 2) == ['AA', 'CC', 'GG', 'TT']
def test_filter_distance_2(self):
assert filter_distance(all_barcodes(2), 3) == ['AA']
def test_filter_distance_3(self):
assert len(filter_distance(all_barcodes(4), 2)) == 64
def test_filter_distance_4(self):
assert len(filter_distance(all_barcodes(4), 3)) == 12
def test_filter_distance_5(self):
assert len(filter_distance(all_barcodes(5), 2)) == 256
def test_filter_distance_6(self):
assert len(filter_distance(all_barcodes(5), 3)) == 36
def test_filter_stretches_1(self):
assert filter_stretches(all_barcodes(2), 1) == ['AC', 'AG', 'AT', 'CA',
'CG', 'CT', 'GA', 'GC', 'GT', 'TA', 'TC', 'TG']
def test_filter_stretches_2(self):
assert len(filter_stretches(all_barcodes(3), 1)) == 36
def test_filter_stretches_3(self):
assert len(filter_stretches(all_barcodes(3), 2)) == 60
def test_filter_stretches_4(self):
assert len(filter_stretches(all_barcodes(4), 1)) == 108
def test_filter_stretches_5(self):
assert len(filter_stretches(all_barcodes(4), 2)) == 228
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