Esempio n. 1
0
def test_render_simple_csv():
    renderer = renderers.CSV({})
    req = DummyRequest()
    sys = {'request': req}
    value = {'header': ['One', 'Two'], 'rows': [[1, 2], [3, 4]]}

    assert renderer(value, sys) == "One,Two\r\n1,2\r\n3,4\r\n"
Esempio n. 2
0
def test_render_unicode_csv():
    renderer = renderers.CSV({})
    req = DummyRequest()
    sys = {'request': req}
    value = {'header': [u'ӓ', u'č'],
             'rows': [[u'ñ', u'あ'], [u'ﺕ', u'Ӫ']]}

    assert renderer(value, sys) == u"ӓ,č\r\nñ,あ\r\nﺕ,Ӫ\r\n".encode('utf-8')
Esempio n. 3
0
def test_response_content_type(pyramid_request):
    renderer = renderers.CSV({})
    renderer({}, {'request': pyramid_request})
    assert pyramid_request.response.content_type == 'text/csv'
Esempio n. 4
0
def test_render_simple_csv(pyramid_request):
    renderer = renderers.CSV({})
    sys = {'request': pyramid_request}
    value = {'header': ['One', 'Two'], 'rows': [[1, 2], [3, 4]]}

    assert renderer(value, sys) == "One,Two\r\n1,2\r\n3,4\r\n"
Esempio n. 5
0
def test_response_content_type():
    renderer = renderers.CSV({})
    req = DummyRequest()
    renderer({}, {'request': req})
    assert req.response.content_type == 'text/csv'