コード例 #1
0
def test_get_line(dbsession, get_csrf_request_with_db, sheet, expensetype):
    request = get_csrf_request_with_db()
    request.context = sheet
    sheet.lines.append(ExpenseLine(tva=1960, ht=150, type_object=expensetype))
    dbsession.merge(sheet)
    dbsession.flush()
    line = request.context.lines[-1]
    request.matchdict = {'lid': line.id}
    view = RestExpenseLine(request)
    assert view.getOne() == line
    request.matchdict = {'lid': 0}
    view = RestExpenseLine(request)
    with pytest.raises(RestError):
        view.getOne()
コード例 #2
0
ファイル: test_expense.py プロジェクト: w3bcr4ft/autonomie
def test_post_line(get_csrf_request_with_db, sheet, expensetype):
    request = get_csrf_request_with_db()
    request.context = sheet
    appstruct = {'ht':'150.0',
                    'tva':'15',
                    'description':'Test',
                    'date':'2112-10-12',
                    'category':'1',
                    'type_id': expensetype.id}
    request.json_body = appstruct
    view = RestExpenseLine(request)
    view.post()
    line = sheet.lines[-1]
    assert line.tva == 1500
    assert line.ht == 15000
    assert line.date == date(2112, 10, 12)
    assert line.type_id == expensetype.id
    assert line.category == u"1"
    assert isinstance(line, ExpenseLine)