def test_json_response_should_serialize_through_simplejson():
    "json_response() should serialize data with simplejson"
    mocker = Mox()

    mocker.StubOutWithMock(controllers, 'simplejson')
    controllers.simplejson.dumps('should-be-data'). \
        AndReturn('should-be-jsonified-data')

    mocker.ReplayAll()
    try:
        got = controllers.json_response('should-be-data')
        assert_equals(got, 'should-be-jsonified-data')
        assert_equals(cherrypy.response.headers['Content-Type'],
                      'text/plain')
        mocker.VerifyAll()
    finally:
        mocker.UnsetStubs()
def test_json_response_should_change_response_content_type():
    "json_response() should change response content-type to text/plain"
    controllers.json_response('should-be-data')
    assert_equals(cherrypy.response.headers['Content-Type'],
                  'text/plain')