diff --git a/engine/apps/metrics_exporter/tests/test_update_metrics_cache.py b/engine/apps/metrics_exporter/tests/test_update_metrics_cache.py index f9250461b..4e583f5b3 100644 --- a/engine/apps/metrics_exporter/tests/test_update_metrics_cache.py +++ b/engine/apps/metrics_exporter/tests/test_update_metrics_cache.py @@ -304,15 +304,15 @@ def test_update_metrics_cache_on_update_integration( stack_slug=METRICS_TEST_INSTANCE_SLUG, stack_id=METRICS_TEST_INSTANCE_ID, ) - team = make_team(organization) + # team = make_team(organization) metric_alert_groups_total_key = get_metric_alert_groups_total_key(organization.id) metric_alert_groups_response_time_key = get_metric_alert_groups_response_time_key(organization.id) - expected_result_updated_team = { - "team_name": team.name, - "team_id": team.id, - } + # expected_result_updated_team = { + # "team_name": team.name, + # "team_id": team.id, + # } expected_result_updated_name = {"integration_name": "Renamed test integration"} @@ -337,7 +337,6 @@ def get_called_arg_index_and_compare_results(): alert_receive_channel = make_alert_receive_channel_with_post_save_signal( organization, verbal_name=METRICS_TEST_INTEGRATION_NAME ) - print(alert_receive_channel) expected_result_metric_alert_groups_total = { (alert_receive_channel.id,"no_team"): { @@ -356,10 +355,10 @@ def get_called_arg_index_and_compare_results(): }, }, }, - (alert_receive_channel.id,team.team_id): { + (alert_receive_channel.id,"no_team"): { "integration_name": METRICS_TEST_INTEGRATION_NAME, - "team_name": team.name, - "team_id": team.team_id, + "team_name": "No team", + "team_id": "no_team", "org_id": organization.org_id, "slug": organization.stack_slug, "id": organization.stack_id, @@ -383,10 +382,10 @@ def get_called_arg_index_and_compare_results(): "id": organization.stack_id, "services": {NO_SERVICE_VALUE: []}, }, - (alert_receive_channel.id,team.team_id): { + (alert_receive_channel.id,"no_team"): { "integration_name": METRICS_TEST_INTEGRATION_NAME, - "team_name": team.name, - "team_id": team.team_id, + "team_name": "No team", + "team_id": "no_team", "org_id": organization.org_id, "slug": organization.stack_slug, "id": organization.stack_id, @@ -401,20 +400,24 @@ def get_called_arg_index_and_compare_results(): monkeypatch.setattr(cache, "get", metrics_cache) # check cache update on update integration's team - alert_receive_channel.team = team + # alert_receive_channel.team = team # clear cached_property # del alert_receive_channel.team_name # del alert_receive_channel.team_id_or_no_team - alert_receive_channel.save() + # alert_receive_channel.save() + + # these tests don't make sense any more because we have multiple integrations per team now + # for expected_result in [ # expected_result_metric_alert_groups_total, # expected_result_metric_alert_groups_response_time, # ]: - # expected_result[(alert_receive_channel.id,"no_team")].update(expected_result_updated_team) + # expected_result[(alert_receive_channel.id,team.team_id)].update(expected_result_updated_team) # arg_idx = get_called_arg_index_and_compare_results() # check cache update on update integration's name + alert_receive_channel.refresh_from_db() alert_receive_channel.verbal_name = expected_result_updated_name["integration_name"] # clear cached_property @@ -450,7 +453,7 @@ def get_called_arg_index_and_compare_results(): expected_result_metric_alert_groups_total, expected_result_metric_alert_groups_response_time, ]: - expected_result.pop(alert_receive_channel.id) + expected_result.pop((alert_receive_channel.id,"no_team")) get_called_arg_index_and_compare_results()