Ejemplo n.º 1
0
class TestPanda(unittest.TestCase):
    def setUp(self):
        self.ivo = Panda("Ivo", "*****@*****.**", "male")

    def test_panda_init(self):
        self.assertEqual(self.ivo.name(), "Ivo")
        self.assertEqual(self.ivo.gender(), "male")
        self.assertEqual(self.ivo.email(), "*****@*****.**")

    # def test_panda_mail_is_not_valid(self):
    #     with self.assertRaises(ValueError):
    #         Panda("Rado", "*****@*****.**", "male")

    def test_panda_str(self):
        self.assertEqual(str(self.ivo), "Ivo is a male panda with email: [email protected]")

    # def test_panda_repr(self):
    #     pass

    def test_panda_eq(self):
        ivo2 = Panda("Ivo", "*****@*****.**", "male")
        rado = Panda("Rado", "*****@*****.**", "male")
        self.assertEqual(self.ivo, ivo2)
        self.assertNotEqual(self.ivo, rado)

    # def test_hash(self):
    #     pass

    def test_name(self):
        self.assertEqual(self.ivo.name(), "Ivo")
        self.assertNotEqual(self.ivo.name(), "Rado")

    def test_mail(self):
        self.assertEqual(self.ivo.email(), "*****@*****.**")
        self.assertNotEqual(self.ivo.email(), "*****@*****.**")

    def test_gender(self):
        self.assertEqual(self.ivo.gender(), "male")
        self.assertNotEqual(self.ivo.gender(), "female")

    def test_isMale(self):
        mimi = Panda("Mimi", "*****@*****.**", "female")
        self.assertTrue(self.ivo.isMale())
        self.assertFalse(mimi.isMale())

    def test_isFemale(self):
        mimi = Panda("Mimi", "*****@*****.**", "female")
        self.assertFalse(self.ivo.isFemale())
        self.assertTrue(mimi.isFemale())
class TestPanda(unittest.TestCase):
    def setUp(self):
        self.ivo = Panda('Ivo', '*****@*****.**', 'male')

    def test_str(self):
        self.assertEqual(str(self.ivo), "Ivo")

    def test_eq(self):
        rado = Panda('rado', '*****@*****.**', 'male')
        rado2 = Panda('Ivo', '*****@*****.**', 'male')
        self.assertFalse(self.ivo == rado)
        self.assertTrue(self.ivo == rado2)

    def test_name(self):
        self.assertEqual(self.ivo.name(), 'Ivo')

    def test_email(self):
        self.assertEqual(self.ivo.email(), '*****@*****.**')

    def test_gender(self):
        self.assertEqual(self.ivo.gender(), 'male')

    def test_is_male(self):
        self.assertTrue(self.ivo.isMale())

    def test_is_female(self):
        self.assertFalse(self.ivo.isFemale())