From 7a1f2b2d064a44577d1c5b1f0e172ae91921a14f Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Tue, 8 Feb 2022 14:30:31 +0100 Subject: [PATCH] Fix the expiration by version logic (#450) * Fix the expiration by version logic * Address review comments --- CHANGELOG.md | 2 ++ glean_parser/util.py | 2 +- tests/test_parser.py | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5b5825..a4640361 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix the logic for the metric expiration by version ([bug 1753194](https://bugzilla.mozilla.org/show_bug.cgi?id=1753194)) + ## 5.0.0 - Remove C# support ([#436](https://github.com/mozilla/glean_parser/pull/436)). diff --git a/glean_parser/util.py b/glean_parser/util.py index 708207c6..8d14ddaf 100644 --- a/glean_parser/util.py +++ b/glean_parser/util.py @@ -418,7 +418,7 @@ def is_expired(expires: str, major_version: Optional[int] = None) -> bool: elif expires == "expired": return True elif major_version is not None: - return parse_expiration_version(expires) >= major_version + return parse_expiration_version(expires) <= major_version else: date = parse_expiration_date(expires) return date <= datetime.datetime.utcnow().date() diff --git a/tests/test_parser.py b/tests/test_parser.py index 0fd0063b..391eb2bf 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -641,7 +641,11 @@ def test_expire_by_major_version(): "category": { "metric_expired_version": { "type": "boolean", - "expires": 18, + "expires": 7, + }, + "metric_expired_edge": { + "type": "boolean", + "expires": 15, }, "metric_expired": { "type": "boolean", @@ -649,7 +653,7 @@ def test_expire_by_major_version(): }, "metric": { "type": "boolean", - "expires": 7, + "expires": 18, }, } } @@ -666,6 +670,7 @@ def test_expire_by_major_version(): errors = list(all_metrics) assert len(errors) == 0 assert all_metrics.value["category"]["metric_expired_version"].disabled is True + assert all_metrics.value["category"]["metric_expired_edge"].disabled is True assert all_metrics.value["category"]["metric_expired"].disabled is True assert all_metrics.value["category"]["metric"].disabled is False