def test_client(self): o = object() s = service.Service(o) self.assertIs(s.client, o) with self.assertRaises(AttributeError): s.client = o
def test_shutdown(self): o = object() s = service.Service(o) def coro(): return yield with unittest.mock.patch.object(s, "_shutdown") as _shutdown: _shutdown.return_value = coro() run_coroutine(s.shutdown()) self.assertSequenceEqual([ unittest.mock.call(), ], _shutdown.mock_calls)
def test_custom_logger(self): l = logging.getLogger("foo") s = service.Service(None, logger_base=l) self.assertEqual(s.logger, l.getChild("service.Service"))