def test_get_processor_info(self, config_rollback): """I dont get why has been configured is True""" client, config_sample_path = config_rollback response = client.get("/config/info") # Expected response config = get_config_file_json(config_sample_path) has_been_configured = bool(config["app"]["has_been_configured"]) device = config["detector"]["device"] if config["detector"]["name"] == "openvino": device += "-openvino" from constants import PROCESSOR_VERSION expected_response = { "version": PROCESSOR_VERSION, "device": device, "has_been_configured": has_been_configured } assert response.status_code == 200 assert response.json() == expected_response
def test_get_global_report(self, config_rollback): client, config_sample_path = config_rollback response = client.get("/config/global_report") config = get_config_file_json(config_sample_path) app_config = config["app"] expected_response = { "emails": app_config["global_reporting_emails"], "time": app_config["global_report_time"], "daily": app_config["daily_global_report"], "weekly": app_config["weekly_global_report"] } assert response.status_code == 200 assert response.json() == expected_response
def get_all_cameras(config_sample_path, with_image=False): config_file_json = get_config_file_json(config_sample_path, decamelize=True) list_of_cameras = { "cameras": [config_file_json[camera] for camera in config_file_json if camera.startswith("source__")]} for camera in list_of_cameras["cameras"]: camera.update({"id": str(camera["id"])}) if with_image: from api.routers.cameras import get_camera_default_image_string image_string = get_camera_default_image_string(camera["id"]) camera["image"] = image_string.decode("utf-8") else: camera["image"] = None return list_of_cameras
def expected_response(config_sample_path): config_directory = config_utils.get_area_config_directory(get_config()) config_path = os.path.join(config_directory, ALL_AREAS + ".json") with open(config_path, "r") as file: json_content_from_file = json.load(file)["global_area_all"] response = {re.sub(r'(?<!^)(?=[A-Z])', '_', key).lower(): value for key, value in json_content_from_file.items()} cameras = ",".join(str(value["id"]) for key, value in get_config_file_json(config_sample_path).items() if key.startswith("source__")) response["cameras"] = cameras response["occupancy_rules"] = get_area_occupancy_rules(ALL_AREAS) response = to_boolean_if_possible(response) return response
def expected_response_update_report_info(config_sample_path): app_config = get_config_file_json(config_sample_path) expected_response = app_config_file_multi_type_json_to_string_json(app_config) expected_response["app"]["has_been_configured"] = "False" return expected_response