Esempio n. 1
0
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)
Esempio n. 2
0
 def testModifica(self):
     nota = Nota(10, 1, 7, 3.5)
     self.ctr.modifica_nota(nota)
     result_nota = self.ctr.cauta_nota(nota)
     self.assertEquals(nota.get_idNota(), result_nota.get_idNota())
     self.assertEquals(nota.get_idStudent(), result_nota.get_idStudent())
     self.assertEquals(nota.get_idDisciplina(),
                       result_nota.get_idDisciplina())
     self.assertEquals(nota.get_punctaj(), result_nota.get_punctaj())
     key_nota = Nota(50, 0, 0, 0)
     self.assertRaises(ValidationException, self.ctr.modifica_nota,
                       key_nota)
     key_nota = Nota(50, 2, 7, 6.2)
     self.assertRaises(RepoException, self.ctr.modifica_nota, key_nota)