def RequestDetailsTest(db): rqd = RequestDetails(1, "test1", "test", "test", "test", "test", "test", "test") assert rqd.id == 1 assert len(rqd.getAll()) == 8 assert equal_tuples(rqd.getAll(), (1, "test1", "test", "test", "test", "test", "test", "test")) rqd.setAll((12, "test12", "test2", "tes2t", "tes2t", "tes3t", "te4st", "tes5t")) assert equal_tuples(rqd.getAll(), (12, "test12", "test2", "tes2t", "tes2t", "tes3t", "te4st", "tes5t")) assert db.isConnectionOk() == 1 db.executeDoQuery("DROP TABLE IF EXISTS requestDetails") db.executeDoQuery( "CREATE TABLE IF NOT EXISTS requestDetails(id INTEGER PRIMARY KEY,detail1 text,detail2 text,detail3 text,detail4 text,detail5 text,detail6 text,needs text,FOREIGN KEY(id) REFERENCES request(id))" ) reqDB = RequestDetailsDBInterface(db) request = RequestDetails(1, "test", "", "", "", "", "", "") request.id = reqDB.add(request) assert request.id != 0 request = reqDB.get(request) assert request.detail1 == "test" request.detail1 = "test2" reqDB.update(request) request = reqDB.get(request) assert request.detail1 == "test2" a = reqDB.getAll() assert len(a) == 1 assert a[0].detail1 == "test2" a = reqDB.getByID(1) assert a.detail1 == "test2" print("Passed RequestDetails test")
def RequestDetailsTest(db): rqd = RequestDetails(1, 'test1', 'test', 'test', 'test', 'test', 'test', 'test') assert (rqd.id == 1) assert (len(rqd.getAll()) == 8) assert (equal_tuples( rqd.getAll(), (1, 'test1', 'test', 'test', 'test', 'test', 'test', 'test'))) rqd.setAll( (12, 'test12', 'test2', 'tes2t', 'tes2t', 'tes3t', 'te4st', 'tes5t')) assert (equal_tuples( rqd.getAll(), (12, 'test12', 'test2', 'tes2t', 'tes2t', 'tes3t', 'te4st', 'tes5t'))) assert (db.isConnectionOk() == 1) db.executeDoQuery("DROP TABLE IF EXISTS requestDetails") db.executeDoQuery( "CREATE TABLE IF NOT EXISTS requestDetails(id INTEGER PRIMARY KEY,detail1 text,detail2 text,detail3 text,detail4 text,detail5 text,detail6 text,needs text,FOREIGN KEY(id) REFERENCES request(id))" ) reqDB = RequestDetailsDBInterface(db) request = RequestDetails(1, 'test', '', '', '', '', '', '') request.id = reqDB.add(request) assert (request.id != 0) request = reqDB.get(request) assert (request.detail1 == 'test') request.detail1 = 'test2' reqDB.update(request) request = reqDB.get(request) assert (request.detail1 == 'test2') a = reqDB.getAll() assert (len(a) == 1) assert (a[0].detail1 == 'test2') a = reqDB.getByID(1) assert (a.detail1 == 'test2') print('Passed RequestDetails test')
def get(self,request): ans = self.database.executeKnowQuery('SELECT * FROM requestDetails WHERE id = ?', (request.id,)) if (len(ans) == 0): return False ans=ans[0] ret = RequestDetails() ret.setAll(ans) return ret
def get(self, request): ans = self.database.executeKnowQuery( 'SELECT * FROM requestDetails WHERE id = ?', (request.id, )) if (len(ans) == 0): return False ans = ans[0] ret = RequestDetails() ret.setAll(ans) return ret
def getAll(self): ans = self.database.executeKnowQuery('SELECT * from requestDetails') if (len(ans) == 0): return False ret = [] for row in ans: temp = RequestDetails() temp.setAll(row) ret.append(temp) return ret
def getAll(self): ans= self.database.executeKnowQuery('SELECT * from requestDetails') if (len(ans)==0): return False ret=[] for row in ans: temp = RequestDetails() temp.setAll(row) ret.append(temp) return ret