# Path: scripts/trimmer.py
# def trim(source_left, source_right, dest_left, dest_right):
#     fastq_pairs = itertools.izip(
#         FastqStanza.stanza_generator(source_left), FastqStanza.stanza_generator(source_right))
#     for (left_stanza, right_stanza) in fastq_pairs:
#         FastqStanza.trim_to_shortest_sequence_length(left_stanza, right_stanza)
#         dest_left.write(left_stanza.as_text())
#         dest_right.write(right_stanza.as_text())


import unittest
from scripts.trimmer import trim


class MockReader():
    def __init__(self, content):
        lines = [line + "\n" for line in content.split("\n") if line != ""]
        self._iter = lines.__iter__()
        self.wasClosed = False

    def __iter__(self):
        return self._iter

    def next(self):
        self._iter.next()

    def close(self):
        self.wasClosed=True


class MockWriter():
    def __init__(self):
        self._content = []
        self.wasClosed = False

    def write(self, content):
        self._content.append(content)
        
    def lines(self):
        return "".join(self._content).splitlines()

    def close(self):

# Path: scripts/trimmer.py
# def trim(source_left, source_right, dest_left, dest_right):
#     fastq_pairs = itertools.izip(
#         FastqStanza.stanza_generator(source_left), FastqStanza.stanza_generator(source_right))
#     for (left_stanza, right_stanza) in fastq_pairs:
#         FastqStanza.trim_to_shortest_sequence_length(left_stanza, right_stanza)
#         dest_left.write(left_stanza.as_text())
#         dest_right.write(right_stanza.as_text())


# Path: test/trimmer_test.py
import unittest
from scripts.trimmer import trim



class MockReader():
    def __init__(self, content):
        lines = [line + "\n" for line in content.split("\n") if line != ""]
        self._iter = lines.__iter__()
        self.wasClosed = False

    def __iter__(self):
        return self._iter

    def next(self):
        self._iter.next()

    def close(self):
        self.wasClosed=True


class MockWriter():
    def __init__(self):
        self._content = []
        self.wasClosed = False

    def write(self, content):
        self._content.append(content)
        
    def lines(self):
        return "".join(self._content).splitlines()

    def close(self):

        self.wasClosed = True