class TestCaseDomain(unittest.TestCase): def setUp(self): self.student1 = Student(1, 'bogdan') self.student2 = Student(1, 'alex') self.disciplina1 = Disciplina(1, 'informatica', 'prof1') self.disciplina2 = Disciplina(1, 'matematica', 'prof2') self.nota1 = Nota(1, 1, 1, 5.5) self.nota2 = Nota(1, 2, 2, 8.6) def tearDown(self): unittest.TestCase.tearDown(self) def testStudent(self): self.assertEquals(self.student1.get_idStudent(), 1) self.assertEquals(self.student1.get_nume(), 'bogdan') self.assertEquals(str(self.student1), '1 bogdan') self.assertEquals(self.student1, self.student2) def testDisciplina(self): self.assertEquals(self.disciplina1.get_idDisciplina(), 1) self.assertEquals(self.disciplina1.get_nume(), 'informatica') self.assertEquals(self.disciplina1.get_profesor(), 'prof1') self.assertEquals(str(self.disciplina1), '1 informatica prof1') self.assertEquals(self.disciplina1, self.disciplina2) def testNota(self): self.assertEquals(self.nota1.get_idNota(), 1) self.assertEquals(self.nota1.get_idStudent(), 1) self.assertEquals(self.nota1.get_idDisciplina(), 1) self.assertEquals(self.nota1.get_punctaj(), 5.5) self.assertEquals(str(self.nota1), '1 1 1 5.5') self.assertEquals(self.nota1, self.nota2)
def testModifica(self): disciplina3 = Disciplina(1, 'fundamentele programarii', 'prof3') self.ctr.modifica_disciplina(disciplina3) result_disc = self.ctr.cauta_disciplina(disciplina3) self.assertEquals(disciplina3.get_idDisciplina(), result_disc.get_idDisciplina()) self.assertEquals(disciplina3.get_nume(), result_disc.get_nume()) self.assertEquals(disciplina3.get_profesor(), result_disc.get_profesor()) key_disc = Disciplina(5, '', '') self.assertRaises(ValidationException, self.ctr.modifica_disciplina, key_disc) key_disc = Disciplina(5, 'sport', 'prof5') self.assertRaises(RepoException, self.ctr.modifica_disciplina, key_disc)