def test_constructor(self, app): w = Worker(app) assert w.app is app assert w.sensors == set() assert w.workdir == Path.cwd() assert isinstance(w.spinner, terminal.Spinner) w2 = Worker(app, redirect_stdouts=False) assert not w2.redirect_stdouts w3 = Worker(app, redirect_stdouts_level="DEBUG") assert w3.redirect_stdouts_level == 10 w4 = Worker(app, logging_config={"foo": 1}) assert w4.logging_config == {"foo": 1}
def test_constructor(self, app): w = Worker(app) assert w.app is app assert w.sensors == set() assert w.workdir == Path.cwd() assert w.Website == symbol_by_name(WEBSITE_CLS) assert w.web_port is None assert w.web_bind is None assert w.web_host == socket.gethostname() assert isinstance(w.spinner, terminal.Spinner)
def test_website(self, app): with patch('faust.web.site.Website') as Website: worker = Worker(app) website = worker.website Website.assert_called_once_with( worker.app, bind=worker.web_bind, port=worker.web_port, loop=worker.loop, beacon=worker.beacon, ) assert website is Website()
def test_set_workdir(self, app): assert Worker(app, workdir="/foo").workdir == Path("/foo")
def test_set_sensors(self, app): assert Worker(app, sensors=[1, 2]).sensors == {1, 2}
def worker(self, app): return Worker(app)
def test_set_workdir(self, app): assert Worker(app, workdir='/foo').workdir == Path('/foo')
def test_constructor(self, app): w = Worker(app) assert w.app is app assert w.sensors == set() assert w.workdir == Path.cwd() assert isinstance(w.spinner, terminal.Spinner)
def test_set_web_host(self, app): assert Worker(app, web_host='foo').web_host == 'foo'
def test_set_web_bind(self, app): assert Worker(app, web_bind='***').web_bind == '***'
def test_set_web_port(self, app): assert Worker(app, web_port=8080).web_port == 8080
def test_set_website(self, app): assert Worker(app, Website='unittest.mock.Mock').Website is Mock
def worker(self, app): return Worker(app, web_port=8080)