Exemple #1
0
def search(sid, did):
    """
    URL args:
        text <required>: search text
        type <optional>: type of object to be searched.
    """
    text = request.args.get('text', None)
    obj_type = request.args.get('type', None)

    so_obj = SearchObjectsHelper(sid, did, blueprint.show_system_objects())

    status, res = so_obj.search(text, obj_type)

    if not status:
        return internal_server_error(errormsg=res)

    return make_json_response(data=res)
Exemple #2
0
    def runTest(self, get_driver_mock, get_node_blueprint_mock):
        manager = self.__create_manager()

        get_driver_mock.return_value = MagicMock(
            connection_manager=lambda session_id: manager)

        def __get_node_blueprint_mock(node_type):
            blueprints = self.node_blueprints
            blueprint = None
            for data in blueprints:
                if node_type == data['node_type']:
                    blueprint = MagicMock(
                        backend_supported=MagicMock(
                            return_value=data['backend_supported']),
                        collection_label=data['coll_label'],
                        show_node=data['backend_supported'],
                    )
            return blueprint

        get_node_blueprint_mock.side_effect = __get_node_blueprint_mock

        with self.app.app_context():

            so_obj = SearchObjectsHelper(2,
                                         18456,
                                         node_types=self.all_node_types)
            so_obj.get_sql = MagicMock(return_value='dummy query')

            # test template path
            manager.server_type = 'pg'
            manager.version = 906000
            self.assertEquals(so_obj.get_template_path(),
                              'search_objects/sql/pg/#906000#')

            self.assertEquals(so_obj.get_show_node_prefs(),
                              self.expected_show_node_prefs)

            self.assertEquals(so_obj.get_supported_types(),
                              self.expected_supported_types)

            self.assertEquals(so_obj.get_supported_types(skip_check=True),
                              self.expected_supported_types_skip)

            self.assertEquals(so_obj.search('searchtext', 'all'),
                              self.expected_search_op)
Exemple #3
0
def types(sid, did):
    so_obj = SearchObjectsHelper(sid, did, blueprint.show_system_objects())
    return make_json_response(data=so_obj.get_supported_types())