import unittest
import io
import re
from unittest import mock
import math
import copy
import inspect
import student_X as main #Replace student_X with your filename 
    
    
    
 

class GetComplementTests(unittest.TestCase):

    def test_default_case(self):
        function = main.Oligo.get_complement
        
        test = False
        try:
            incorrect = ""
            result = function.__doc__
            result = result.strip()
            test =  result != incorrect
        except:
            pass
        message = "No docstring."
        self.assertTrue(test, message)

        

        a = main.Oligo('A')
        b = main.Oligo('T')

        inputs = (a)
        tested_inputs = inputs #change this if you need to test specific inputs

        #expected answers
        correct_inputs = inputs
        correct_result = b
        correct_printed = ""

        #run the test
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            if isinstance(inputs, tuple):
                result = function(*inputs)
            else:
                result = function(inputs)
        printed_output = fake_stdout.getvalue().strip()

        test = correct_printed == printed_output
        message = "Shouldn't print anything out."
        self.assertTrue(test, message)
        test = result == correct_result
        message = "Doesn't work when the subject is an Oligo with only one base."
        self.assertTrue(test, message)
        test = tested_inputs == correct_inputs
        message = "Modifies the inputs."
        self.assertTrue(test, message)

        

        a = main.Oligo('ACGT')
        b = main.Oligo('ACGT')

        inputs = (a)
        tested_inputs = inputs #change this if you need to test specific inputs

        #expected answers
        correct_inputs = inputs
        correct_result = b
        correct_printed = ""

        #run the test
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            if isinstance(inputs, tuple):
                result = function(*inputs)
            else:
                result = function(inputs)
        printed_output = fake_stdout.getvalue().strip()


        test = not result == main.Oligo('TGCA')
        message = "The complement's bases are in the backwards order."
        self.assertTrue(test, message)
        test = correct_printed == printed_output
        message = "Shouldn't print anything out."
        self.assertTrue(test, message)
        test = result == correct_result
        message = "Doesn't work on ACGT."
        self.assertTrue(test, message)
        test = tested_inputs == correct_inputs
        message = "Modifies the inputs."
        self.assertTrue(test, message)

        

        a = main.Oligo('AACTGCTG')
        b = main.Oligo('CAGCAGTT')

        inputs = (a)
        tested_inputs = inputs #change this if you need to test specific inputs

        #expected answers
        correct_inputs = inputs
        correct_result = b
        correct_printed = ""

        #run the test
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            if isinstance(inputs, tuple):
                result = function(*inputs)
            else:
                result = function(inputs)
        printed_output = fake_stdout.getvalue().strip()

        test = correct_printed == printed_output
        message = "Shouldn't print anything out."
        self.assertTrue(test, message)
        test = result == correct_result
        message = "Doesn't return the correct complement for a long Oligo."
        self.assertTrue(test, message)
        test = tested_inputs == correct_inputs
        message = "Modifies the inputs."
        self.assertTrue(test, message)





        
        
if __name__ == "__main__":
    tests = GetComplementTests()
    tests.test_default_case()