From 23a7463f166c4d04050040589a99d83769fe224f Mon Sep 17 00:00:00 2001 From: Bruno Dufour Date: Wed, 4 Dec 2024 09:54:21 -0500 Subject: [PATCH] Make version test resilient to new fields --- .../nativeapp/__snapshots__/test_version.ambr | 6 ------ tests_integration/nativeapp/test_version.py | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests_integration/nativeapp/__snapshots__/test_version.ambr b/tests_integration/nativeapp/__snapshots__/test_version.ambr index 8c0ac6e37a..fcc3c0c6bc 100644 --- a/tests_integration/nativeapp/__snapshots__/test_version.ambr +++ b/tests_integration/nativeapp/__snapshots__/test_version.ambr @@ -3,24 +3,18 @@ list([ dict({ 'comment': None, - 'dropped_on': None, 'label': '', - 'log_level': 'OFF', 'patch': 0, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'OFF', 'version': 'V1', }), dict({ 'comment': None, - 'dropped_on': None, 'label': '', - 'log_level': 'OFF', 'patch': 1, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'OFF', 'version': 'V1', }), ]) diff --git a/tests_integration/nativeapp/test_version.py b/tests_integration/nativeapp/test_version.py index ce9706afba..701f9e9fc0 100644 --- a/tests_integration/nativeapp/test_version.py +++ b/tests_integration/nativeapp/test_version.py @@ -31,6 +31,17 @@ from tests_integration.test_utils import contains_row_with, row_from_snowflake_session +# A minimal set of fields to compare when checking version output +VERSION_FIELDS_TO_OUTPUT = [ + "comment", + "label", + "patch", + "review_status", + "state", + "version", +] + + def set_version_in_app_manifest(manifest_path: Path, version: Any, patch: Any = None): with open(manifest_path, "r") as f: manifest = safe_load(f) @@ -373,10 +384,10 @@ def test_nativeapp_version_create_package_no_magic_comment( # app package contains version v1 with 2 patches actual = runner.invoke_with_connection_json(split(list_command)) for row in actual.json: - # Remove date field - row.pop("created_on", None) - # Remove metric_level field - row.pop("metric_level", None) + keys_to_remove = row.keys() - VERSION_FIELDS_TO_OUTPUT + for key in keys_to_remove: + del row[key] + assert actual.json == snapshot