Hi, Thanks to the AlterEgo Post (http://www.web2py.com/AlterEgo/default/ show/260) and to deep search on the group, i've set up a test.py file. Yet, i am trying to update the database (my controller aims at changing main parameters of the app).
Here is my main code : class TestParameters(unittest.TestCase): def setUp(self): request = Request() # Use a clean Request object execfile("applications/init/controllers/parameters.py", globals()) db.commit() def new_param(self, paramdb): # Set variables for the test function request.vars.db = paramdb #Create a new record and check if id is an int self.dParams = json.loads(new_record()) db.commit() self.assertTrue(type(int(self.dParams['id'])) == type(1)) def test_param_ressources(self): """ Test the addition of a new ressource and editing it """ def new_ressource(): request = Request() # Use a clean Request object self.result = json.loads(new_record("ressources")) db.commit() def edit_ressource(): #add request vars request.vars.update(dict({'tr_id':self.result["id"], 'db':"ressources", 'name':"My Ressource", 'begda':"26/02/2000", 'endda':"31/05/2020"})) #decode json and check data result = json.loads(edit_record()) db.commit() self.assertEqual(len(result["errors"]), new_ressource() edit_ressource() def test_param_statuses(self): """ Test the addition of a new status and editing it """ def new_status(): request = Request() # Use a clean Request object self.result = json.loads(new_record("statuses")) def edit_status(): #add request vars request.vars.update(dict({'tr_id':self.result["id"], 'db':"statuses", 'status':"STA", 'description':"My Unit Test status", 'cut':"off"})) #decode json and check data result = json.loads(edit_record()) db.commit() self.assertEqual(len(result["errors"]), new_status() edit_status() The edit_record() function belongs to the parameters.py controller. My problem is : when i do logger.debug(request.vars) in the edit_record() function, on the second call (when adding new status), it displays the whole request.vars, i mean, i do also have request.vars from ressources (begda, endda...). I thought the request = Request() would reset and clead the request object. I've simplified the code to make it readable but it keeps the logic. Could someone tell me what i am doing wrong ? Thanks for your help, Jérémie