def test_DiscoverUrlsFromBlueprint_UrlPrefix(self):
        """
        Registers a blueprint into an application with 'url_prefix'
        Collects routes from url_map that gets mapped to name of a view_function or endpoint.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST DISCOVER URLS FROM BLUEPRINT -- URL PREFIX ======")

        test_url_prefix = "/test_prefix"

        self.app1.register_blueprint(self.public_blueprint1,
                                     url_prefix=test_url_prefix)

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        blueprint_links = [link for link in self.app1.ud_links if '.' in link]

        link_list = [
            self.app1.ud_links[link]['active_urls'][0]
            for link in blueprint_links
        ]
        # print(link_list)
        [self.assertTrue(test_url_prefix in link) for link in link_list]
    def test_DiscoverUrlsFromBlueprint(self):
        """
        Registers a blueprint into an application
        Collects routes from url_map that gets mapped to name of a view_function or endpoint.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST DISCOVER URLS FROM BLUEPRINT ======")

        self.app1.register_blueprint(self.public_blueprint1)

        print(self.app1.url_map)

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(sorted(list(self.app1.ud_links.keys())),
                         sorted(app1_registered_blueprint))
    def test_PrivateBlueprint(self):
        """
        Privates a blueprint.
        Registers a blueprint into an application.
        Collects routes from url_map that gets mapped to name of a view_function or endpoint.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST PRIVATE BLUEPRINT ======")

        app2 = Flask(__name__)

        private(self.private_blueprint)
        app2.register_blueprint(self.private_blueprint)

        discover_urls(app2)
        print("Collected Links: ", app2.ud_links)
        self.assertEqual(sorted(list(app2.ud_links.keys())), sorted(app1_private_blueprint_links))
    def test_DiscoverUrlsMultipleRules(self):
        """
        Assigns multiple rules to an endpoint
        Collects routes from url_map that gets mapped to name of a view_function or endpoint.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST DISCOVER URLS MULTIPLE RULES ======")

        @self.app1.route('/test/multiple/')
        @self.app1.route('/test/routes/')
        def multiple_routes():
            return

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(
            len(self.app1.ud_links['multiple_routes']['active_urls']), 2)
    def test_PrivateLink_CustomEndpoint(self):
        """
        Adds a private rule to an app with custom endpoint.
        Validates that the added rule was hidden and not exposed
        :return: void
        """
        print()
        print("====== TEST PRIVATE LINK -- CUSTOM ENDPOINT ======")

        @private()
        @self.app1.route("/test/hidden_rule/", endpoint="test_endpoint1")
        def test_endpoint():
            """
            Test url_rule + view_function. Custom endpoint is used
            :return: void
            """
            return

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(sorted(list(self.app1.ud_links.keys())), sorted(app1_simple_case_links))
    def test_PrivateLink(self):
        """
        Adds a private rule to an app.
        Validates that the added rule was hidden and not exposed
        :return: void
        """
        print()
        print("====== TEST PRIVATE LINK ======")

        @private()
        @self.app1.route("/test/hidden_rule/")
        def hidden_rule():
            """
            Test url_rule + view_function
            :return: void
            """
            return

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(sorted(list(self.app1.ud_links.keys())), sorted(app1_simple_case_links))
    def test_DiscoverUrlsCustomEndpoint(self):
        """
        Collects routes from url_map that gets mapped to name of a view_function or endpoint.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST DISCOVER URLS CUSTOM ENDPOINT ======")

        @self.app1.route('/test/custom_endpoint', endpoint='test_endpoint')
        def test_route2():
            """
            Test url_rule + view_function. Custom endpoint is used
            :return: void
            """
            return

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(sorted(list(self.app1.ud_links.keys())),
                         sorted(app1_custom_endpoint_ud_links))
    def test_DiscoverUrls(self):
        """
        Collects routes from url_map that gets mapped to name of a view_function.
        Validates result dictionary that gets stored directly in the flask application
        :return: void
        """
        print()
        print("====== TEST DISCOVER URLS SIMPLE ======")

        @self.app1.route('/test/second_rule')
        def test_route2():
            """
            Test url_rule + view_function
            :return: void
            """
            return

        discover_urls(self.app1)
        print("Collected Links: ", self.app1.ud_links)
        self.assertEqual(sorted(list(self.app1.ud_links.keys())),
                         sorted(app1_simple_case_links))