def getIt(self): elem = self.getOne() request = self.get_csrf_request() request.context = self.sheet(request) request.matchdict['lid'] = elem.id view = RestExpenseKmLine(request) return view.getOne()
def test_get_kmline(get_csrf_request_with_db, sheet_with_kmline): """ Check the rest api return the same line object """ line = sheet_with_kmline.kmlines[-1] request = get_csrf_request_with_db() request.context = sheet_with_kmline request.matchdict['lid'] = line.id view = RestExpenseKmLine(request) rest_line = view.getOne() assert line.id == rest_line.id
def addOne(self): request = self.get_csrf_request() request.context = self.sheet(request) appstruct = {'km':'150.0', 'start':'point a', 'end':'point b', 'description':'Test', 'date':'2112-10-12', 'category':'1', 'type_id':1} request.json_body = appstruct view = RestExpenseKmLine(request) view.post()
def sheet_with_kmline(get_csrf_request_with_db, sheet, expensekmtype): request = get_csrf_request_with_db() request.context = sheet appstruct = {'km':'150.0', 'start':'point a', 'end':'point b', 'description':'Test', 'date':'2112-10-12', 'category':'1', 'type_id': expensekmtype.id} request.json_body = appstruct view = RestExpenseKmLine(request) view.post() return sheet
def test_put_kmline(get_csrf_request_with_db, sheet_with_kmline, expensekmtype): line = sheet_with_kmline.kmlines[-1] appstruct = {'km':'12.0', "start":"point a2", "end":"point b2", "date":line.date.isoformat(), "description":line.description, "category":line.category, "type_id":line.type_id} request = get_csrf_request_with_db() request.context = sheet_with_kmline request.matchdict['lid'] = line.id request.json_body = appstruct view = RestExpenseKmLine(request) view.put() assert line.km == 1200 assert line.start == u"point a2" assert line.end == u"point b2" assert line.type_id == expensekmtype.id
def test_put(self): self.addOne() line = self.getOne() appstruct = {'km':'12.0', "start":"point a2", "end":"point b2", "date":line.date.isoformat(), "description":line.description, "category":line.category, "type_id":line.type_id} request = self.get_csrf_request() request.context = self.sheet(request) request.matchdict['lid'] = line.id request.json_body = appstruct view = RestExpenseKmLine(request) view.put() line = self.getOne() self.assertEqual(line.km, 1200) self.assertEqual(line.start, u"point a2") self.assertEqual(line.end, u"point b2") self.assertEqual(line.type_id, 1)