コード例 #1
0
ファイル: test_index_service.py プロジェクト: cgwire/zou
 def test_search_assets_after_creation(self):
     assets = index_service.search_assets("girafe", self.project_ids)
     self.assertEqual(len(assets), 0)
     assets_service.create_asset(self.project_id, self.asset_type_id,
                                 "Girafe", "", {})
     assets = index_service.search_assets("girafe", self.project_ids)
     self.assertEqual(len(assets), 1)
コード例 #2
0
ファイル: test_index_service.py プロジェクト: cgwire/zou
 def test_search_assets_after_deletion(self):
     asset = assets_service.create_asset(self.project_id,
                                         self.asset_type_id, "Girafe", "",
                                         {})
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 1)
     assets_service.remove_asset(asset["id"])
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 0)
コード例 #3
0
ファイル: test_index_service.py プロジェクト: cgwire/zou
 def test_search_assets_after_update(self):
     asset = assets_service.create_asset(self.project_id,
                                         self.asset_type_id, "Girafe", "",
                                         {})
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 1)
     assets_service.update_asset(asset["id"], {"name": "Elephant"})
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 0)
     assets = index_service.search_assets("elephant")
     self.assertEqual(len(assets), 1)
コード例 #4
0
ファイル: commands.py プロジェクト: cgwire/zou
def search_asset(query):
    assets = index_service.search_assets(query)
    if len(assets) == 0:
        print("No asset found")
    for asset in assets:
        print(asset["name"], asset["id"])
    return assets
コード例 #5
0
    def post(self):
        """
        Search for resource
        ---
        tags:
        - Search
        parameters:
          - in: query
            name: query
            required: True
            schema:
                type: string
                example: name of asset
        responses:
            200:
                description: Resource
        """
        args = self.get_args([("query", "", True)])
        query = args.get("query")
        if len(query) < 3:
            return {"assets": []}

        if permissions.has_admin_permissions():
            projects = projects_service.open_projects()
        else:
            projects = user_service.get_open_projects()
        persons = index_service.search_persons(query)
        open_project_ids = [project["id"] for project in projects]

        return {
            "assets": index_service.search_assets(query, open_project_ids),
            "persons": persons,
        }
コード例 #6
0
ファイル: test_search.py プロジェクト: cgwire/zou
 def test_search_assets_after_update(self):
     asset = self.create_girafe_asset()
     assets = index_service.search_assets("girafe")
     self.assertEqual(len(assets), 1)
     self.put("data/entities/%s" % asset["id"], {"name": "Elephant"})
     assets = self.post("data/search", {"query": "girafe"}, 200)["assets"]
     self.assertEqual(len(assets), 0)
     assets = self.post("data/search", {"query": "elephant"}, 200)["assets"]
     self.assertEqual(len(assets), 1)
コード例 #7
0
ファイル: test_index_service.py プロジェクト: cgwire/zou
 def test_search_assets_partial(self):
     assets = index_service.search_assets("rabb", self.project_ids)
     self.assertEqual(len(assets), 1)
     assets = index_service.search_assets("usten", self.project_ids)
     self.assertEqual(len(assets), 1)
コード例 #8
0
ファイル: test_index_service.py プロジェクト: cgwire/zou
 def test_search_assets_exact(self):
     assets = index_service.search_assets("rabbit", self.project_ids)
     self.assertEqual(len(assets), 1)