def test_serves_forever(self, tcp_server, observer_cls): httpd = mock.MagicMock() tcp_server.return_value = httpd observer = mock.MagicMock() observer_cls.return_value = observer serve(self.site, self.director) self.assertTrue(httpd.serve_forever.called) self.assertTrue(observer.start.called)
def test_server_quits_on_keyboard_interrupt(self, tcp_server, observer_cls): httpd = mock.MagicMock() httpd.serve_forever.side_effect = KeyboardInterrupt tcp_server.return_value = httpd observer = mock.MagicMock() observer_cls.return_value = observer serve(self.site, self.director) self.assertTrue(observer.stop.called)
def test_server_quits_on_keyboard_interrupt( self, tcp_server, observer_cls): httpd = mock.MagicMock() httpd.serve_forever.side_effect = KeyboardInterrupt tcp_server.return_value = httpd observer = mock.MagicMock() observer_cls.return_value = observer serve(self.site, self.director) self.assertTrue(observer.stop.called)
def test_server_quits_on_keyboard_interrupt( self, tcp_server, observer_cls): httpd = mock.MagicMock() httpd.serve_forever.side_effect = KeyboardInterrupt tcp_server.return_value = httpd observer = mock.MagicMock() observer_cls.return_value = observer try: serve(self.site, self.director) except KeyboardInterrupt: self.fail('Server did not quit gracefully.') self.assertTrue(observer.stop.called)
def run(self, args): site = Site.build(args) director = prepare_director(args, site) director.produce() serve(site, director)