Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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