示例#1
0
 def __init__(self, registry=None):
     """Constructor."""
     registry = registry or prometheus_client.REGISTRY
     # Here registry is explicit to allow us to mess with it in the tests.
     self.gourde = gourde.Gourde(__name__, registry=registry)
     self.app = self.gourde.app
     self.accessor = None
     self.args = None
示例#2
0
 def test_basic(self):
     """Create a gourde from a name."""
     g = gourde.Gourde(__name__, registry=self.registry)
     testutils.setup(g)
     g.setup()
     self.assertIsNotNone(g)
     self.assertTrue(g.is_healthy())
     self.assertTrue(g.is_ready())
     self.assertIsNotNone(g.metrics)
示例#3
0
    def test_disable_embedded_logging_should_prevent_logging_from_being_configured(self):
        logger = mockito.mock()
        app = flask.Flask(__name__)
        app.logger = logger

        g = gourde.Gourde(app, registry=self.registry)

        testutils.setup(g, ["--disable-embedded-logging"])

        mockito.verify(logger, times=0).addHandler(mockito.any())
        mockito.verify(logger, times=0).setLevel(mockito.any())
示例#4
0
    def test_logging_should_be_enabled_by_default(self):
        logger = mockito.mock()
        app = flask.Flask(__name__)
        app.logger = logger

        g = gourde.Gourde(app, registry=self.registry)

        testutils.setup(g, [])

        mockito.verify(logger, times=1).addHandler(mockito.any())
        mockito.verify(logger, times=1).setLevel(mockito.any())
        mockito.verify(logger, times=1).info("Logging initialized.")
示例#5
0
 def test_flask(self):
     """Create a gourde with a flask."""
     app = flask.Flask(__name__)
     g = gourde.Gourde(app, registry=self.registry)
     testutils.setup(g)
     self.assertIsNotNone(g)