Ejemplo n.º 1
0
    def test_build_versioned_handlers_with_health(self):
        endpoint = MagicMock()
        endpoint.name = "foobar"
        endpoint.handlers = [
            ("/test0", "TEST0"),
            ("/test1", "TEST1"),
        ]
        endpoint.health_checks = True  # must evaluate to True
        active_version = '2'
        deprecated_versions = ['1']
        deprecated_handler = "DEPRECATED"
        expected = [
            ("/v2/foobar/_health", HealthHandler, {"endpoint": endpoint}),
            ("/v2/foobar/test0", "TEST0", {"endpoint": endpoint}),
            ("/v2/foobar/test1", "TEST1", {"endpoint": endpoint}),
            ("/v1/foobar/test0", "DEPRECATED"),
            ("/v1/foobar/test1", "DEPRECATED"),
        ]

        versioned = build_versioned_handlers(
            endpoint,
            active_version,
            deprecated_versions,
            deprecated_handler)
        self.assertEqual(versioned, expected)
Ejemplo n.º 2
0
    def test_build_versioned_handlers_long_handler(self):
        endpoint = MagicMock()
        endpoint.name = "foobar"
        endpoint.handlers = [
            ("/test0", "TEST0", {"ADDITIONAL": True}),
            ("/test1", "TEST1"),
        ]
        endpoint.health_checks = []
        active_version = '2'
        deprecated_versions = ['1']
        deprecated_handler = "DEPRECATED"
        expected = [
            ("/v2/foobar/test0", "TEST0", {"ADDITIONAL": True,
                                           "endpoint": endpoint}),
            ("/v2/foobar/test1", "TEST1", {"endpoint": endpoint}),
            ("/v1/foobar/test0", "DEPRECATED"),
            ("/v1/foobar/test1", "DEPRECATED"),
        ]

        versioned = build_versioned_handlers(
            endpoint,
            active_version,
            deprecated_versions,
            deprecated_handler)
        self.assertEqual(versioned, expected)