def test_main_with_no_ioloop(): argv = [] loop = FakeLoop() main(args=argv, main_loop=None, app=App, server_impl=FakeServer, get_ioloop=get_fake_ioloop(loop)) forget()
def test_main_works_as_expected(): argv = [] main_loop = FakeLoop() main(args=argv, main_loop=main_loop, app=App, server_impl=FakeServer) expect(App.called_with).to_include('config') expect(App.called_with).to_include('log_level') expect(App.called_with).to_include('debug') expect(App.called_with).to_include('main_loop') expect(App.called_with['log_level']).to_equal('ERROR') expect(App.called_with['debug']).to_be_false() expect(main_loop.started).to_be_true() expect(FakeServer.called_with).to_include('application') expect(FakeServer.called_with['application']).to_be_instance_of(App) expect(FakeServer.called_with).to_include('xheaders') expect(FakeServer.called_with['xheaders']).to_be_true() expect(FakeServer.called_with).to_include('port') expect(FakeServer.called_with['port']).to_equal(9999) expect(FakeServer.called_with).to_include('ip') expect(FakeServer.called_with['ip']).to_equal("0.0.0.0") expect(FakeServer.called_with).to_include('procs') expect(FakeServer.called_with['procs']).to_equal(1) forget()
def test_main_works_as_expected(): argv = [] main_loop = FakeLoop() main(args=argv, main_loop=main_loop, app=App, server_impl=FakeServer) expect(App.called_with).to_include('config') expect(App.called_with).to_include('debug') expect(App.called_with).to_include('main_loop') expect(App.called_with['debug']).to_be_false() expect(main_loop.started).to_be_true() expect(FakeServer.called_with).to_include('application') expect(FakeServer.called_with['application']).to_be_instance_of(App) expect(FakeServer.called_with).to_include('xheaders') expect(FakeServer.called_with['xheaders']).to_be_true() expect(FakeServer.called_with).to_include('port') expect(FakeServer.called_with['port']).to_equal(9999) expect(FakeServer.called_with).to_include('ip') expect(FakeServer.called_with['ip']).to_equal("0.0.0.0") expect(FakeServer.called_with).to_include('procs') expect(FakeServer.called_with['procs']).to_equal(1) forget()
def test_main_with_debug(): argv = ['--debug'] main_loop = FakeLoop() main(args=argv, main_loop=main_loop, app=App, server_impl=FakeServer) expect(App.called_with).to_include('debug') expect(App.called_with['debug']).to_be_true() forget()
def test_main_with_custom_config(): working_text = "GNIKROW" argv = ['--conf', './tests/test.conf'] main_loop = FakeLoop() main(args=argv, main_loop=main_loop, app=App, server_impl=FakeServer) expect(App.called_with).to_include('config') expect(App.called_with['config'].HEALTHCHECK_TEXT).to_equal(working_text) forget()
def test_main_with_port_and_bind(): argv = ['--port', '7654', '--bind', '1.2.3.4'] main_loop = FakeLoop() main(args=argv, main_loop=main_loop, app=App, server_impl=FakeServer) expect(FakeServer.called_with).to_include('port') expect(FakeServer.called_with['port']).to_equal(7654) expect(FakeServer.called_with).to_include('ip') expect(FakeServer.called_with['ip']).to_equal("1.2.3.4") forget()