import io

import pytest

import kmer_counter


class TestCount(object):
    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)

    def test_with_record_length_2_and_kmer_length_3_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('AA', 3)

    def test_with_record_size_3_returns_kmer_size_3(self):
        # given
        record = 'AAA'

        # when
        count = kmer_counter.count(record, 3)

        # then
        assert list(count.keys()) == [record]
        assert list(count.values()) == [1]

    def test_with_record_size_4_returns_one_kmer_count_2(self):
        # given
        record = 'AAAA'
        kmer_size = 3
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert list(count.keys()) == [record[:kmer_size]]
        assert list(count.values()) == [2]

    def test_with_two_kmers_returns_two_kmers_size_3(self):
        # given
        record = 'AAAT'
        kmer_size = 3
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert count['AAA'] == 1
        assert count['AAT'] == 1

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        # given
        record = 'AT'
        kmer_size = 1
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):
    def test_returns_one_string_from_fh_with_one_record(self):
        # given
        file_handle = io.StringIO('>seq1\nAAAAA\n')

        # when
        record = next(kmer_counter.fasta_records(file_handle))

        # then
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'

64cd403fc6f2486da38d7d4a2c31436b2b6ebf6b
<mask token>


class TestCount(object):

    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        record = 'AT'
        kmer_size = 1
        count = kmer_counter.count(record, kmer_size)
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):

    def test_returns_one_string_from_fh_with_one_record(self):
        file_handle = io.StringIO('>seq1\nAAAAA\n')
        record = next(kmer_counter.fasta_records(file_handle))
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'

<mask token>


class TestCount(object):

    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)
    <mask token>

    def test_with_record_size_3_returns_kmer_size_3(self):
        record = 'AAA'
        count = kmer_counter.count(record, 3)
        assert list(count.keys()) == [record]
        assert list(count.values()) == [1]
    <mask token>

    def test_with_two_kmers_returns_two_kmers_size_3(self):
        record = 'AAAT'
        kmer_size = 3
        count = kmer_counter.count(record, kmer_size)
        assert count['AAA'] == 1
        assert count['AAT'] == 1

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        record = 'AT'
        kmer_size = 1
        count = kmer_counter.count(record, kmer_size)
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):

    def test_returns_one_string_from_fh_with_one_record(self):
        file_handle = io.StringIO('>seq1\nAAAAA\n')
        record = next(kmer_counter.fasta_records(file_handle))
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'

<mask token>


class TestCount(object):

    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)
    <mask token>

    def test_with_record_size_3_returns_kmer_size_3(self):
        record = 'AAA'
        count = kmer_counter.count(record, 3)
        assert list(count.keys()) == [record]
        assert list(count.values()) == [1]

    def test_with_record_size_4_returns_one_kmer_count_2(self):
        record = 'AAAA'
        kmer_size = 3
        count = kmer_counter.count(record, kmer_size)
        assert list(count.keys()) == [record[:kmer_size]]
        assert list(count.values()) == [2]

    def test_with_two_kmers_returns_two_kmers_size_3(self):
        record = 'AAAT'
        kmer_size = 3
        count = kmer_counter.count(record, kmer_size)
        assert count['AAA'] == 1
        assert count['AAT'] == 1

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        record = 'AT'
        kmer_size = 1
        count = kmer_counter.count(record, kmer_size)
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):

    def test_returns_one_string_from_fh_with_one_record(self):
        file_handle = io.StringIO('>seq1\nAAAAA\n')
        record = next(kmer_counter.fasta_records(file_handle))
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'

import io
import pytest
import kmer_counter


class TestCount(object):

    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)

    def test_with_record_length_2_and_kmer_length_3_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('AA', 3)

    def test_with_record_size_3_returns_kmer_size_3(self):
        record = 'AAA'
        count = kmer_counter.count(record, 3)
        assert list(count.keys()) == [record]
        assert list(count.values()) == [1]

    def test_with_record_size_4_returns_one_kmer_count_2(self):
        record = 'AAAA'
        kmer_size = 3
        count = kmer_counter.count(record, kmer_size)
        assert list(count.keys()) == [record[:kmer_size]]
        assert list(count.values()) == [2]

    def test_with_two_kmers_returns_two_kmers_size_3(self):
        record = 'AAAT'
        kmer_size = 3
        count = kmer_counter.count(record, kmer_size)
        assert count['AAA'] == 1
        assert count['AAT'] == 1

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        record = 'AT'
        kmer_size = 1
        count = kmer_counter.count(record, kmer_size)
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):

    def test_returns_one_string_from_fh_with_one_record(self):
        file_handle = io.StringIO('>seq1\nAAAAA\n')
        record = next(kmer_counter.fasta_records(file_handle))
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'

import io

import pytest

import kmer_counter


class TestCount(object):
    def test_with_empty_record_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('', 3)

    def test_with_kmer_size_0_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('A', 0)

    def test_with_record_length_2_and_kmer_length_3_raises(self):
        with pytest.raises(AssertionError):
            kmer_counter.count('AA', 3)

    def test_with_record_size_3_returns_kmer_size_3(self):
        # given
        record = 'AAA'

        # when
        count = kmer_counter.count(record, 3)

        # then
        assert list(count.keys()) == [record]
        assert list(count.values()) == [1]

    def test_with_record_size_4_returns_one_kmer_count_2(self):
        # given
        record = 'AAAA'
        kmer_size = 3
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert list(count.keys()) == [record[:kmer_size]]
        assert list(count.values()) == [2]

    def test_with_two_kmers_returns_two_kmers_size_3(self):
        # given
        record = 'AAAT'
        kmer_size = 3
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert count['AAA'] == 1
        assert count['AAT'] == 1

    def test_with_two_kmers_returns_two_kmers_size_1(self):
        # given
        record = 'AT'
        kmer_size = 1
        # when
        count = kmer_counter.count(record, kmer_size)

        # then
        assert count['A'] == 1
        assert count['T'] == 1


class TestFastaRecords(object):
    def test_returns_one_string_from_fh_with_one_record(self):
        # given
        file_handle = io.StringIO('>seq1\nAAAAA\n')

        # when
        record = next(kmer_counter.fasta_records(file_handle))

        # then
        assert record.desc == 'seq1'
        assert record.seq == 'AAAAA'
