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 GeographicCoordinateStrTests(unittest.TestCase):

    def test_default_case(self):
        incorrect = ""
        try:
            doc = main.GeographicCoordinate.__init__.__doc__
            doc = doc.strip()
        except:
            doc = ""
        test = incorrect != doc
        message = "No docstring for the __init__."
        self.assertTrue(test, message)

        
        function = main.GeographicCoordinate.__str__
        incorrect = ""
        try:
            doc = function.__doc__
            doc = doc.strip()
        except:
            doc = ""
        test = incorrect != doc
        message = "No docstring."
        self.assertTrue(test, message)

        
        try:
            latitude = main.GeographicCoordinate('N', 1, 0, 0)
        except:
            latitude = None
        test = latitude != None
        message = "GeographicCoordinate init failed."
        self.assertTrue(test, message)


        #main.Pokemon.__eq__ = lambda x,y: x.name == y.name and x.number == y.number and x.types == y.types and x.hit_points == y.hit_points and x.max_hp == y.max_hp

        inputs = (latitude)

        #expected answers
        correct_inputs = inputs
        correct_result = "1\N{DEGREE SIGN}0'0\"N"
        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 "’" in result
        message = "Output includes a back tick (’) instead of an apostrophe (') for minutes."
        self.assertTrue(test, message)

        test = "\N{DEGREE SIGN}" in result
        message = "Output doesn't include the degree symbol.  (\N{DEGREE SIGN})"
        self.assertTrue(test, message)
        test = result.endswith("N")
        message = "Output doesn't end with an 'N' for a north latitude."
        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 a Northwards coordinate with zero minutes and zero seconds."
        self.assertTrue(test, message)
        test = inputs == correct_inputs
        message = "Inputs modified."
        self.assertTrue(test, message)

        

        try:
            latitude = main.GeographicCoordinate('N', 44, 16, 13.8)
        except:
            latitude = None
        test = latitude != None
        message = "GeographicCoordinate init failed."
        self.assertTrue(test, message)


        #main.Pokemon.__eq__ = lambda x,y: x.name == y.name and x.number == y.number and x.types == y.types and x.hit_points == y.hit_points and x.max_hp == y.max_hp

        inputs = (latitude)

        #expected answers
        correct_inputs = inputs
        correct_result = "44\N{DEGREE SIGN}16'13.8\"N"
        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 on a Northwards latitude coordinate."
        self.assertTrue(test, message)
        test = inputs == correct_inputs
        message = "Inputs modified."
        self.assertTrue(test, message)

        

        try:
            latitude = main.GeographicCoordinate('S', 25, 10, 15.2)
        except:
            latitude = None
        test = latitude != None
        message = "GeographicCoordinate init failed."
        self.assertTrue(test, message)


        #main.Pokemon.__eq__ = lambda x,y: x.name == y.name and x.number == y.number and x.types == y.types and x.hit_points == y.hit_points and x.max_hp == y.max_hp

        inputs = (latitude)

        #expected answers
        correct_inputs = inputs
        correct_result = "25\N{DEGREE SIGN}10'15.2\"S"
        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 = result.endswith("S")
        message = "Doesn't end with an S when it's a Southward latitude."
        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 a Southwards latitude coordinate."
        self.assertTrue(test, message)
        test = inputs == correct_inputs
        message = "Inputs modified."
        self.assertTrue(test, message)

        

        try:
            latitude = main.GeographicCoordinate('W', 99, 35, 45.7)
        except:
            latitude = None
        test = latitude != None
        message = "GeographicCoordinate init failed on a longitude coordinate."
        self.assertTrue(test, message)

        inputs = (latitude)

        #expected answers
        correct_inputs = inputs
        correct_result = "99\N{DEGREE SIGN}35'45.7\"W"
        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 = result.endswith("W")
        message = "Doesn't end with an W when it's a Westward longitude."
        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 a Westward longitude coordinate."
        self.assertTrue(test, message)
        test = inputs == correct_inputs
        message = "Inputs modified."
        self.assertTrue(test, message)

        

        try:
            latitude = main.GeographicCoordinate('E', 115, 35, 45.7)
        except:
            latitude = None
        test = latitude != None
        message = "GeographicCoordinate init failed on a longitude coordinate."
        self.assertTrue(test, message)

        inputs = (latitude)

        #expected answers
        correct_inputs = inputs
        correct_result = "115\N{DEGREE SIGN}35'45.7\"E"
        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 = result.endswith("E")
        message = "Doesn't end with an E when it's a Eastward longitude."
        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 a Eastward longitude coordinate."
        self.assertTrue(test, message)
        test = inputs == correct_inputs
        message = "Inputs modified."
        self.assertTrue(test, message)




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