Beispiel #1
0
def test_null_handler():
    with mock.patch.object(NullHandler, '__init__', return_value=None), \
         mock.patch.object(NullHandler, 'write') as m_write, \
         mock.patch.object(NullHandler, 'set_header') as m_set_header:
        h = NullHandler()
        h.initialize(context=object(),
                     interface=Config.Interface('foo', '', 1, 0, []))
        h.get()

    m_write.assert_called_once_with("Interface 'foo' works!\n")
    m_set_header.assert_called_once_with("Content-Type",
                                         "text/plain; charset=UTF-8")
Beispiel #2
0
def test_null_handler():
    app = tornado.web.Application([],
                                  context=object(),
                                  interface=Config.Interface(name='foo',
                                                             host='',
                                                             port=1,
                                                             unix_socket=None,
                                                             processes=0,
                                                             urls=[]))
    req = mock.Mock()

    with mock.patch.object(NullHandler, 'write') as m_write:
        with mock.patch.object(NullHandler, 'set_header') as m_set_header:
            h = NullHandler(app, req)
            h.get()

    m_write.assert_called_once_with("Interface 'foo' works!\n")
    m_set_header.assert_called_once_with("Content-Type",
                                         "text/plain; charset=UTF-8")