def deploy_button(self, resid, erd, username, inciid): assert isinstance(resid, int) assert isinstance(inciid, int) today = str(datetime.datetime.today().date()) sql = "UPDATE Resource SET startDate ='{0}', DueDate = '{1}', CurrentStatus = 'not available', CurrentUser = '******' WHERE ResourceID = {3};" run_sql_string_statement(sql.format(today, str(erd), username, resid)) self.resreqdao.delete_by_resIdAndInciId(resid, inciid)
def test_more(self): srd = Search_Result_DataService() resd = Resource_DAO() rep = RepairResource_DAO() reqeust = ResourceRequest_DAO() count_for_test = run_sql_string_statement( "select count(*) from Resource") count = int(count_for_test[0][0]) a = count + 1 b = count + 2 resd.insert_resource(a, "123Name", "dummy", "not available", 14.56, 33.12, "james", 120.4, 3, "hour", "tom", "2015-03-02", "2016-07-03") resd.insert_resource(b, "123Name", "dummy", "in repair", 14.56, 33.12, "james", 120.4, 3, "hour", "tom", "2015-03-02", "2016-07-03") rep.insert_records(b, rep.get_count() + 1, "james", "2015-03-02", "2016-07-03") reqeust.insert_record(1, reqeust.get_count() + 1, "2015-03-02", a) ma = srd.populate_table_data("a", "2# aaa", 1000000, "(6) testinci") assert isinstance(ma, list) print ma
def res_request_by_username(self, username): assert isinstance(username, str) finalresult = list() sql = "SELECT ResourceID, IncidentID FROM ResourceRequest WHERE IncidentID in (SELECT IncidentID FROM Incident WHERE Incident.username ='******');" sql = sql.format(username) temp_result = run_sql_string_statement(sql) if len(temp_result) == 0 or len(temp_result[0]) == 0: return finalresult templist = list() for row in temp_result: rowtemp = list() resid = int(row[0]) incid = int(row[1]) sql = "SELECT ResourceName, Owner, DueDate FROM Resource WHERE ResourceID = {0};".format(resid) t1 = run_sql_string_statement(sql) if len(t1) == 0 or len(t1[0]) == 0: rowtemp.append(resid) rowtemp.append("") rowtemp.append("") rowtemp.append("") rowtemp.append("") rowtemp.append("") else: rowtemp.append(resid) rowtemp.append(t1[0][0]) rowtemp.append(self.incidao.get_incident_description_by_incidentId(incid)) rowtemp.append(self.userdao.get_nameinfo_by_username(t1[0][1])) rowtemp.append(str(t1[0][2])) rowtemp.append(incid) finalresult.append(rowtemp) return finalresult
def request_received_me(self, username): assert isinstance(username, str) finalresult = list() sql = "SELECT ResourceID, RequestID, ExpectedReturnDate, IncidentID FROM ResourceRequest WHERE ResourceID in (SELECT ResourceID from Resource WHERE Resource.Owner ='{0}');" sql = sql.format(username) temp_result = run_sql_string_statement(sql) if len(temp_result) == 0 or len(temp_result[0]) == 0: return finalresult templist = list() for row in temp_result: resid = row[0] erd = row[2] incid = row[3] reqid = row[1] t = run_sql_string_statement( "SELECT CurrentStatus, ResourceName, DueDate FROM Resource WHERE ResourceID = {0};".format( int(row[0]))) templist.append(resid) templist.append(self.resdao.get_resname_by_resourceId(int(resid))) templist.append(self.incidao.get_incident_description_by_incidentId(int(incid))) templist.append(self.userdao.get_nameinfo_by_username(username)) templist.append(str(erd)) status = t[0][0] if status != "available": templist.append("reject") else: if self.repairResourcedao.get_count_by_resId(resid) == 0: templist.append("cancelrepair") else: templist.append("deploy-reject") templist.append(incid) finalresult.append(templist) return finalresult
def test_insert_record(self): rsd = Resource_DAO() count_for_test = run_sql_string_statement( "select count(*) from Resource") count = int(count_for_test[0][0]) rsd.insert_resource(count + 1, "123Name", "dummy", "available", 14.56, 33.12, "james", 120.4, 3, "hour", "tom", "2015-03-02", "2016-07-03")
def test(self): print "test the Additional DAO" cpd = Additional_DAO(123) count_for_test = run_sql_string_statement( "select count(*) from Additional") count = int(count_for_test[0][0]) print "count==" + str(count) print cpd.insert_additional_esf_list([3, 4]) rsp = cpd.get_all_additional_under_resourceID() assert isinstance(rsp, list) for item in rsp: print item
def test(self): print "test the Capability DAO" cpd = Capability_DAO(123) count_for_test = run_sql_string_statement("select count(*) from Capability") count = int(count_for_test[0][0]) dummy = list() dummy.append("cap123-" + str(count + 1)) dummy.append("cap123-" + str(count + 2)) print cpd.insert_capability(dummy) rsp = cpd.get_all_capabilities_under_resourceID() assert isinstance(rsp, list) for item in rsp: print item
def usedata(self): sql = "select Resource.EsfID, ESF.item, count(*) from Resource inner join ESF on ESF.EsfID = Resource.EsfID where Resource.CurrentStatus='not available' group by Resource.EsfID order by Resource.EsfID;" result = run_sql_string_statement(sql) fr = list() if len(result) == 0 or len(result[0]) == 0: return fr for row in result: tep = list() tep.append(row[0]) tep.append(row[1]) tep.append(row[2]) fr.append(tep) return fr
def repairtable(self, username): assert isinstance(username, str) sql = "SELECT ResourceID, repairID, startDate, endDate FROM RepairResource WHERE ResourceID in (SELECT ResourceID FROM Resource WHERE Owner ='{0}')"; tempresult = run_sql_string_statement(sql.format(username)) finalre = list() if len(tempresult) == 0 or len(tempresult[0]) == 0: return finalre for row in tempresult: resid = int(row[0]) tm = list() tm.append(resid) tm.append(self.resdao.get_resname_by_resourceId(resid)) tm.append(str(row[2])) tm.append(str(row[3])) finalre.append(tm) return finalre
def populate_res_in_use_tabledata(self, username): assert isinstance(username, str) sql = "SELECT ResourceID, ResourceName, owner, startDate, CurrentUser FROM Resource WHERE ResourceID in (SELECT ResourceID FROM Resource WHERE CurrentUser ='******');" sql = sql.format(username) result = run_sql_string_statement(sql) fr = list() if len(result) == 0 or len(result[0]) == 0: return fr for row in result: tmp = list() tmp.append(row[0]) tmp.append(row[1]) tmp.append(self.userdao.get_nameinfo_by_username(row[2])) tmp.append(str(row[3])) tmp.append(self.userdao.get_nameinfo_by_username(row[4])) fr.append(tmp) return fr
def return_button(self, resId): assert isinstance(resId, int) sql = "UPDATE Resource SET startDate =NULL, DueDate = NULL, CurrentUser = NULL, CurrentStatus ='available' WHERE ResourceID = {0};" sql = sql.format(resId) result = run_sql_string_statement(sql)