|
|
|
@ -63,10 +63,10 @@ async def test_update_equipment_for_simulation_basic():
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value=mock_reliability_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value=mock_reliability_data), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None) as mock_update_node:
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None):
|
|
|
|
|
|
|
|
|
|
|
|
# Run the function
|
|
|
|
# Run the function
|
|
|
|
results = await update_equipment_for_simulation(
|
|
|
|
res = await update_equipment_for_simulation(
|
|
|
|
db_session=db_session,
|
|
|
|
db_session=db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
project_name=project_name,
|
|
|
|
project_name=project_name,
|
|
|
|
@ -77,15 +77,14 @@ async def test_update_equipment_for_simulation_basic():
|
|
|
|
schematic_name=schematic_name
|
|
|
|
schematic_name=schematic_name
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results = res['reliability']
|
|
|
|
|
|
|
|
equipment_nodes = res['equipment_nodes']
|
|
|
|
|
|
|
|
|
|
|
|
# Assertions
|
|
|
|
# Assertions
|
|
|
|
assert "EQ001" in results
|
|
|
|
assert "EQ001" in results
|
|
|
|
assert results["EQ001"]["distribution"] == "Weibull2"
|
|
|
|
assert results["EQ001"]["distribution"] == "Weibull2"
|
|
|
|
assert results["EQ001"]["oh_duration"] == overhaul_duration
|
|
|
|
assert results["EQ001"]["oh_duration"] == overhaul_duration
|
|
|
|
|
|
|
|
|
|
|
|
# Check if update_node was called with correct arguments
|
|
|
|
|
|
|
|
called_args = mock_update_node.call_args[1]
|
|
|
|
|
|
|
|
equipment_nodes = called_args["equipment_nodes"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Find EQ001 in equipment_nodes
|
|
|
|
# Find EQ001 in equipment_nodes
|
|
|
|
eq001_node = next(node for node in equipment_nodes if node["equipmentName"] == "EQ001")
|
|
|
|
eq001_node = next(node for node in equipment_nodes if node["equipmentName"] == "EQ001")
|
|
|
|
assert eq001_node["relDisType"] == "Weibull2"
|
|
|
|
assert eq001_node["relDisType"] == "Weibull2"
|
|
|
|
@ -144,18 +143,20 @@ async def test_update_equipment_for_simulation_custom_input():
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None):
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None):
|
|
|
|
|
|
|
|
|
|
|
|
# Run
|
|
|
|
# Run
|
|
|
|
results = await update_equipment_for_simulation(
|
|
|
|
res = await update_equipment_for_simulation(
|
|
|
|
db_session=db_session,
|
|
|
|
db_session=db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
project_name=project_name,
|
|
|
|
project_name=project_name,
|
|
|
|
simulation_duration=simulation_duration,
|
|
|
|
simulation_duration=simulation_duration,
|
|
|
|
overhaul_duration=overhaul_duration,
|
|
|
|
overhaul_duration=overhaul_duration,
|
|
|
|
overhaul_interval=overhaul_interval,
|
|
|
|
overhaul_interval=8000,
|
|
|
|
offset=offset,
|
|
|
|
offset=0,
|
|
|
|
schematic_name=schematic_name,
|
|
|
|
schematic_name=schematic_name,
|
|
|
|
custom_input=custom_input
|
|
|
|
custom_input=custom_input
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results = res['reliability']
|
|
|
|
|
|
|
|
|
|
|
|
assert "EQ001" in results
|
|
|
|
assert "EQ001" in results
|
|
|
|
assert results["EQ001"]["mttr"] == 10
|
|
|
|
assert results["EQ001"]["mttr"] == 10
|
|
|
|
assert results["EQ001"]["distribution"] == "Exponential2"
|
|
|
|
assert results["EQ001"]["distribution"] == "Exponential2"
|
|
|
|
@ -200,10 +201,10 @@ async def test_update_equipment_for_simulation_missing_reliability():
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value={}), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value={}), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None) as mock_update_node:
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None):
|
|
|
|
|
|
|
|
|
|
|
|
# Run
|
|
|
|
# Run
|
|
|
|
results = await update_equipment_for_simulation(
|
|
|
|
res = await update_equipment_for_simulation(
|
|
|
|
db_session=db_session,
|
|
|
|
db_session=db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
project_name=project_name,
|
|
|
|
project_name=project_name,
|
|
|
|
@ -214,14 +215,16 @@ async def test_update_equipment_for_simulation_missing_reliability():
|
|
|
|
schematic_name=schematic_name
|
|
|
|
schematic_name=schematic_name
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results = res['reliability']
|
|
|
|
|
|
|
|
equipment_nodes = res['equipment_nodes']
|
|
|
|
|
|
|
|
|
|
|
|
assert "EQ_MISSING" in results
|
|
|
|
assert "EQ_MISSING" in results
|
|
|
|
# Default values when no reliability data
|
|
|
|
# Default values when no reliability data
|
|
|
|
assert results["EQ_MISSING"]["mttr"] == 0
|
|
|
|
assert results["EQ_MISSING"]["mttr"] == 0
|
|
|
|
assert results["EQ_MISSING"]["distribution"] == "Fixed"
|
|
|
|
assert results["EQ_MISSING"]["distribution"] == "Fixed"
|
|
|
|
|
|
|
|
|
|
|
|
# Check defaults in update_node call
|
|
|
|
# Check defaults in returned equipment_nodes
|
|
|
|
called_args = mock_update_node.call_args[1]
|
|
|
|
eq_node = equipment_nodes[0]
|
|
|
|
eq_node = called_args["equipment_nodes"][0]
|
|
|
|
|
|
|
|
assert eq_node["cmDisUnitCode"] == "UHour"
|
|
|
|
assert eq_node["cmDisUnitCode"] == "UHour"
|
|
|
|
assert eq_node["relDisUnitCode"] == "UHour"
|
|
|
|
assert eq_node["relDisUnitCode"] == "UHour"
|
|
|
|
assert eq_node["ohDisUnitCode"] == "UHour"
|
|
|
|
assert eq_node["ohDisUnitCode"] == "UHour"
|
|
|
|
@ -278,10 +281,10 @@ async def test_update_equipment_for_simulation_sigma_constraint():
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_aeros_equipment_by_location_tag", return_value=mock_nodes_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value=mock_reliability_data), \
|
|
|
|
patch("src.aeros_equipment.service.get_asset_batch", return_value=mock_reliability_data), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_oh_interval_offset", return_value=None), \
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None) as mock_update_node:
|
|
|
|
patch("src.aeros_equipment.service.update_node", return_value=None):
|
|
|
|
|
|
|
|
|
|
|
|
# Run
|
|
|
|
# Run
|
|
|
|
await update_equipment_for_simulation(
|
|
|
|
res = await update_equipment_for_simulation(
|
|
|
|
db_session=db_session,
|
|
|
|
db_session=db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
aeros_db_session=aeros_db_session,
|
|
|
|
project_name=project_name,
|
|
|
|
project_name=project_name,
|
|
|
|
@ -292,7 +295,7 @@ async def test_update_equipment_for_simulation_sigma_constraint():
|
|
|
|
schematic_name=schematic_name
|
|
|
|
schematic_name=schematic_name
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Check if sigma was constrained correctly
|
|
|
|
# Check if sigma was constrained correctly in returned equipment_nodes
|
|
|
|
called_args = mock_update_node.call_args[1]
|
|
|
|
equipment_nodes = res['equipment_nodes']
|
|
|
|
eq_node = called_args["equipment_nodes"][0]
|
|
|
|
eq_node = equipment_nodes[0]
|
|
|
|
assert eq_node["relDisP2"] == 999
|
|
|
|
assert eq_node["relDisP2"] == 999
|
|
|
|
|