Esempio n. 1
0
def test_ok():
    handler = APIHandler()
    resp = handler._ok({'tracks': [{'id': 1, 'name': 'Track 1'}]})
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="ok"><tracks><track><id>1</id><name>Track 1</name></track></tracks></response>'
    assert_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
Esempio n. 2
0
def test_ok():
    handler = APIHandler()
    resp = handler._ok({'tracks': [{'id': 1, 'name': 'Track 1'}]})
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="ok"><tracks><track><id>1</id><name>Track 1</name></track></tracks></response>'
    assert_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
Esempio n. 3
0
def test_error():
    handler = APIHandler()
    resp = handler._error(123, 'something is wrong')
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="error"><error>something is wrong</error></response>'
    assert_equals(expected, resp.data)
    assert_equals('400 BAD REQUEST', resp.status)
    resp = handler._error(234, 'oops', status=500)
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="error"><error>oops</error></response>'
    assert_equals(expected, resp.data)
    assert_equals('500 INTERNAL SERVER ERROR', resp.status)
Esempio n. 4
0
def test_error():
    handler = APIHandler()
    resp = handler._error(123, 'something is wrong')
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="error"><error>something is wrong</error></response>'
    assert_equals(expected, resp.data)
    assert_equals('400 BAD REQUEST', resp.status)
    resp = handler._error(234, 'oops', status=500)
    assert_equals('text/xml; charset=UTF-8', resp.content_type)
    expected = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<response status="error"><error>oops</error></response>'
    assert_equals(expected, resp.data)
    assert_equals('500 INTERNAL SERVER ERROR', resp.status)