# Path: src/tests/behave/api/features/common/utils.py
# def get_entity_list_container_field(name):
#     """Returns the container field used in list responses
# 
#     GET /active_computers       -> {"items": [...]}
#     GET /jobs                   -> {"jobs": [...]}
#     """
#     if name == "active_computers":
#         return "items"
#     elif name == "inventory_computers":
#         return "items"
#     elif name == "rpc_tasks":
#         return "tasks"
#     elif name == "rpc_jobs":
#         return "jobs"
#     return name
# 
# def get_entity_id_field(name):
#     """Returns the id field used for entities in list responses
# 
#     GET /active_computers       -> {"items": [{"mercury_id": "...", ...}}]}
#     GET /jobs                   -> {"jobs": [{"job_id": "...", ...}}]}
#     """
#     if name == "active_computers":
#         return "mercury_id"
#     elif name == "inventory_computers":
#         return "mercury_id"
#     elif name == "rpc_tasks":
#         return "task_id"
#     elif name == "rpc_jobs":
#         return "job_id"
#     return name
# 
# def read_json_from_file(filename, location):
#     filename = "{0}/{1}".format(location, filename)
#     with open(filename) as file:
#         data = json.loads(file.read())
#     return data


import json
import operator
from functools import reduce
from behave import given, when, step
from src.tests.behave.api.features.common.utils import (
    get_entity_list_container_field,
    get_entity_id_field,
    read_json_from_file,
)



@given(
    "I have query details in {filename} for entities using the {service_name} api"
)

# Path: src/tests/behave/api/features/common/utils.py
# def get_entity_list_container_field(name):
#     """Returns the container field used in list responses
# 
#     GET /active_computers       -> {"items": [...]}
#     GET /jobs                   -> {"jobs": [...]}
#     """
#     if name == "active_computers":
#         return "items"
#     elif name == "inventory_computers":
#         return "items"
#     elif name == "rpc_tasks":
#         return "tasks"
#     elif name == "rpc_jobs":
#         return "jobs"
#     return name
# 
# def get_entity_id_field(name):
#     """Returns the id field used for entities in list responses
# 
#     GET /active_computers       -> {"items": [{"mercury_id": "...", ...}}]}
#     GET /jobs                   -> {"jobs": [{"job_id": "...", ...}}]}
#     """
#     if name == "active_computers":
#         return "mercury_id"
#     elif name == "inventory_computers":
#         return "mercury_id"
#     elif name == "rpc_tasks":
#         return "task_id"
#     elif name == "rpc_jobs":
#         return "job_id"
#     return name
# 
# def read_json_from_file(filename, location):
#     filename = "{0}/{1}".format(location, filename)
#     with open(filename) as file:
#         data = json.loads(file.read())
#     return data


# Path: src/tests/behave/api/features/steps/query.py
import json
import operator
from functools import reduce
from behave import given, when, step
from src.tests.behave.api.features.common.utils import (
    get_entity_list_container_field,
    get_entity_id_field,
    read_json_from_file,
)




@given(
    "I have query details in {filename} for entities using the {service_name} api"
)

def step_i_have_query_details_in_filename_for_entities_using_the_service_api(