SIENTIAPDE-1169

SIENTIAPDE-1169 Update Redis and core scouter tests to include model_tags in data structures, enhancing data organization and consistency across test cases.
This commit is contained in:
vitor-aignosi
2025-08-19 09:29:46 -03:00
parent 2c0f5a67e6
commit 552f58ca86
2 changed files with 45 additions and 10 deletions

View File

@@ -219,7 +219,11 @@ async def test_group_and_hold_data_new_key(redis_activity):
'name': ['sensor1', 'sensor2'], 'name': ['sensor1', 'sensor2'],
'value': [25.5, 30.0], 'value': [25.5, 30.0],
'timestamp': ['2023-01-01 12:00:00'] * 2 'timestamp': ['2023-01-01 12:00:00'] * 2
}).to_dict('records') }).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
# Mock get to return None for new key # Mock get to return None for new key
@@ -271,7 +275,12 @@ async def test_group_and_hold_data_update_existing(redis_activity):
'name': ['sensor1', 'sensor3'], 'name': ['sensor1', 'sensor3'],
'value': [25.5, 42.0], 'value': [25.5, 42.0],
'timestamp': ['2023-01-01 12:00:00'] * 2 'timestamp': ['2023-01-01 12:00:00'] * 2
}).to_dict('records') }).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2',
'sensor3': 'sensor3'
}
} }
# Mock get to return existing data # Mock get to return existing data
@@ -317,7 +326,11 @@ async def test_group_and_hold_data_with_none_values(redis_activity):
'name': ['sensor1', 'sensor2'], 'name': ['sensor1', 'sensor2'],
'value': [None, 30.0], 'value': [None, 30.0],
'timestamp': [datetime(2023, 1, 1, 12, 0, 0)] * 2 'timestamp': [datetime(2023, 1, 1, 12, 0, 0)] * 2
}).to_dict('records') }).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
# Mock get to return None for new key # Mock get to return None for new key
@@ -341,7 +354,11 @@ async def test_group_and_hold_data_empty_dataframe(redis_activity):
'workflow_name': 'test_workflow', 'workflow_name': 'test_workflow',
'schedule_name': 'test_schedule', 'schedule_name': 'test_schedule',
'retention_time': 3600, 'retention_time': 3600,
'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records') 'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
redis_activity.get = MagicMock(return_value=None) redis_activity.get = MagicMock(return_value=None)
@@ -361,7 +378,11 @@ async def test_group_and_hold_data_error_get(redis_activity):
'schedule_name': 'test_schedule', 'schedule_name': 'test_schedule',
'retention_time': 3600, 'retention_time': 3600,
'model_id': 1, 'model_id': 1,
'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records') 'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
redis_activity.get = MagicMock(side_effect=Exception('test')) redis_activity.get = MagicMock(side_effect=Exception('test'))
@@ -395,7 +416,11 @@ async def test_group_and_hold_data_error_set(redis_activity):
'schedule_name': 'test_schedule', 'schedule_name': 'test_schedule',
'retention_time': 3600, 'retention_time': 3600,
'model_id': 1, 'model_id': 1,
'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records') 'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records'),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
existing_data = { existing_data = {
@@ -434,7 +459,11 @@ async def test_store_data_package(redis_activity):
'name': ['sensor1', 'sensor2'], 'name': ['sensor1', 'sensor2'],
'value': [25.5, 30.0], 'value': [25.5, 30.0],
'timestamp': ['2023-01-01 12:00:00'] * 2 'timestamp': ['2023-01-01 12:00:00'] * 2
}).to_dict() }).to_dict(),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
await redis_activity.store_data_package(test_data) await redis_activity.store_data_package(test_data)
@@ -467,7 +496,11 @@ async def test_store_data_package_error(redis_activity):
'name': ['sensor1', 'sensor2'], 'name': ['sensor1', 'sensor2'],
'value': [25.5, 30.0], 'value': [25.5, 30.0],
'timestamp': ['2023-01-01 12:00:00'] * 2 'timestamp': ['2023-01-01 12:00:00'] * 2
}).to_dict() }).to_dict(),
'model_tags': {
'sensor1': 'sensor1',
'sensor2': 'sensor2'
}
} }
with pytest.raises(Exception): with pytest.raises(Exception):

View File

@@ -80,7 +80,8 @@ async def test_core_scouter_workflow_success(mock_workflow, core_scouter):
'schedule_name': 'test_schedule', 'schedule_name': 'test_schedule',
'data': 'grouped_data', 'data': 'grouped_data',
'model_id': 'test_model_id', 'model_id': 'test_model_id',
'retention_time': 3600 'retention_time': 3600,
'model_tags': {}
}, },
retry_policy=ANY, retry_policy=ANY,
start_to_close_timeout=ANY start_to_close_timeout=ANY
@@ -184,7 +185,8 @@ async def test_core_scouter_workflow_with_empty_data(mock_workflow, core_scouter
'schedule_name': 'test_schedule', 'schedule_name': 'test_schedule',
'data': {}, 'data': {},
'model_id': 'test_model_id', 'model_id': 'test_model_id',
'retention_time': 3600 'retention_time': 3600,
'model_tags': {}
}, },
retry_policy=ANY, retry_policy=ANY,
start_to_close_timeout=ANY start_to_close_timeout=ANY