def get(self,request):
     ans = self.database.executeKnowQuery('SELECT * FROM financialRequest WHERE id = ?', (request.id,))
     if (len(ans) == 0):
         return False
     ans = ans[0]
     ret = FinancialRequest()
     ret.setAll(ans)
     return ret
Esempio n. 2
0
 def get(self, request):
     ans = self.database.executeKnowQuery(
         'SELECT * FROM financialRequest WHERE id = ?', (request.id, ))
     if (len(ans) == 0):
         return False
     ans = ans[0]
     ret = FinancialRequest()
     ret.setAll(ans)
     return ret
 def getByRequestID(self,requestID):
     ans = self.database.executeKnowQuery('SELECT * FROM financialRequest WHERE requestID = ?', (requestID,))
     if (ans== False):
         return False
     ret = []
     for row in ans:
         temp = FinancialRequest()
         temp.setAll(row)
         ret.append(temp)
     return ret
 def getAll(self):
     ans= self.database.executeKnowQuery('SELECT * from financialRequest')
     if (len(ans)==0):
         return False
     ret=[]
     for row in ans:
         temp = FinancialRequest()
         temp.setAll(row)
         ret.append(temp)
     return ret
Esempio n. 5
0
 def getAll(self):
     ans = self.database.executeKnowQuery('SELECT * from financialRequest')
     if (len(ans) == 0):
         return False
     ret = []
     for row in ans:
         temp = FinancialRequest()
         temp.setAll(row)
         ret.append(temp)
     return ret
Esempio n. 6
0
 def getByRequestID(self, requestID):
     ans = self.database.executeKnowQuery(
         'SELECT * FROM financialRequest WHERE requestID = ?',
         (requestID, ))
     if (ans == False):
         return False
     ret = []
     for row in ans:
         temp = FinancialRequest()
         temp.setAll(row)
         ret.append(temp)
     return ret
def FinancialRequestTest(db):
    fr = FinancialRequest(1, "10/10/2015", "dep1", 1, 1000, "test", FinancialRequestStatus.Pending.value)
    assert fr.department == "dep1"
    assert len(fr.getAll()) == 7
    assert equal_tuples(fr.getAll(), (1, "10/10/2015", "dep1", 1, 1000, "test", FinancialRequestStatus.Pending.value))
    fr.setAll((12, "10/12/2015", "dep31", 31, 10300, "te3st", FinancialRequestStatus.Approved.value))
    assert equal_tuples(
        fr.getAll(), (12, "10/12/2015", "dep31", 31, 10300, "te3st", FinancialRequestStatus.Approved.value)
    )
    assert db.isConnectionOk() == 1
    db.executeDoQuery("DROP TABLE IF EXISTS financialRequest")
    db.executeDoQuery(
        "CREATE TABLE IF NOT EXISTS financialRequest(id INTEGER PRIMARY KEY AUTOINCREMENT,date text,department text,requestID integer,amount integer,reason  text,status integer,FOREIGN KEY(requestID) REFERENCES request(id))"
    )

    reqDB = FinancialRequestDBInterface(db)
    request = FinancialRequest(0, "10/10/2015", "Administration", 1, 1000, "Test", FinancialRequestStatus.Pending.value)
    request.id = reqDB.add(request)
    assert request.id != 0
    request = reqDB.get(request)
    assert request.amount == 1000
    request.amount = 2000
    reqDB.update(request)
    request = reqDB.get(request)
    assert request.amount == 2000
    a = reqDB.getAll()
    assert len(a) == 1
    a = a[0]
    assert a.amount == 2000
    a = reqDB.getByRequestID(1)
    assert len(a) == 1
    assert a[0].amount == 2000
    a = reqDB.getByStatus(1)
    assert len(a) == 1
    a = reqDB.getByID(1)
    assert a.amount == 2000
    print("Passed FinancialRequest test")
Esempio n. 8
0
def FinancialRequestTest(db):
    fr = FinancialRequest(1, '10/10/2015', 'dep1', 1, 1000, 'test',
                          FinancialRequestStatus.Pending.value)
    assert (fr.department == 'dep1')
    assert (len(fr.getAll()) == 7)
    assert (equal_tuples(fr.getAll(),
                         (1, '10/10/2015', 'dep1', 1, 1000, 'test',
                          FinancialRequestStatus.Pending.value)))
    fr.setAll((12, '10/12/2015', 'dep31', 31, 10300, 'te3st',
               FinancialRequestStatus.Approved.value))
    assert (equal_tuples(fr.getAll(),
                         (12, '10/12/2015', 'dep31', 31, 10300, 'te3st',
                          FinancialRequestStatus.Approved.value)))
    assert (db.isConnectionOk() == 1)
    db.executeDoQuery("DROP TABLE IF EXISTS financialRequest")
    db.executeDoQuery(
        "CREATE TABLE IF NOT EXISTS financialRequest(id INTEGER PRIMARY KEY AUTOINCREMENT,date text,department text,requestID integer,amount integer,reason  text,status integer,FOREIGN KEY(requestID) REFERENCES request(id))"
    )

    reqDB = FinancialRequestDBInterface(db)
    request = FinancialRequest(0, '10/10/2015', 'Administration', 1, 1000,
                               'Test', FinancialRequestStatus.Pending.value)
    request.id = reqDB.add(request)
    assert (request.id != 0)
    request = reqDB.get(request)
    assert (request.amount == 1000)
    request.amount = 2000
    reqDB.update(request)
    request = reqDB.get(request)
    assert (request.amount == 2000)
    a = reqDB.getAll()
    assert (len(a) == 1)
    a = a[0]
    assert (a.amount == 2000)
    a = reqDB.getByRequestID(1)
    assert (len(a) == 1)
    assert (a[0].amount == 2000)
    a = reqDB.getByStatus(1)
    assert (len(a) == 1)
    a = reqDB.getByID(1)
    assert (a.amount == 2000)
    print("Passed FinancialRequest test")
 def getByID(self, fr_id):
     temp = FinancialRequest()
     temp.id = fr_id
     return self.get(temp)
Esempio n. 10
0
 def getByID(self, fr_id):
     temp = FinancialRequest()
     temp.id = fr_id
     return self.get(temp)