def update(self, obj): Repository.update(self, obj) obj = (obj.Name, obj.Group, obj.Id) sql = '''UPDATE students SET StudName = ? , StudGroup = ? WHERE id = ?''' current = self._conn.cursor() current.execute(sql, obj) self._conn.commit()
def update(self, obj): Repository.update(self, obj) obj = (obj.IdStud, obj.IdAssignment, obj.Grade, obj.Id) sql = '''UPDATE grades SET studId = ?, assignId = ?, grade = ? WHERE id = ?''' current = self._connection.cursor() current.execute(sql, obj) self._connection.commit()
def test_update(self): studs = Repository([]) studs.store(s1 := Student(1234, 'John Doe', 1)) studs.update(Student(1234, 'Jane Doe', 2)) self.assertEqual(studs.getAll[0].Name, 'Jane Doe') self.assertEqual(studs.getAll[0].Group, 2) with self.assertRaises(RepositoryException): studs.update(Student(1235, 'Mark', 12)) studs.getAll[0].Name = 'Jesus' self.assertEqual(studs.getAll[0].Name, 'Jesus') with self.assertRaises(ValueError): s1.Name = 'as' s1.Group = 5 self.assertNotEqual(repr(s1), 0) self.assertEqual(s1 == 0, False) self.assertEqual(s1, Student(1234, 'Mike', 2))
def update(self, obj): Repository.update(self, obj) self._saveFile()