From 869e71ba9226d77c947689699e60f9811cf60f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Kone=C4=8Dn=C3=BD?= Date: Tue, 23 Aug 2022 10:49:57 +0200 Subject: [PATCH] Use __exact when looking for bugzilla mail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to look for exact match when looking for bugzilla mail. This should also be quicker than normal search. Signed-off-by: Michal Konečný --- tests/utils/test_fedora_account_fasjson.py | 2 +- toddlers/utils/fedora_account.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils/test_fedora_account_fasjson.py b/tests/utils/test_fedora_account_fasjson.py index 59ec812..5bd0e16 100644 --- a/tests/utils/test_fedora_account_fasjson.py +++ b/tests/utils/test_fedora_account_fasjson.py @@ -202,7 +202,7 @@ class TestFedoraAccountFASJSON: assert output == {"username": "scoady", "rhbzemail": "scoady@fp.o"} server.search.assert_has_calls( - [call(email="scoady@fp.o"), call(rhbzemail="scoady@fp.o")] + [call(email="scoady@fp.o"), call(rhbzemail__exact="scoady@fp.o")] ) @patch("toddlers.utils.fedora_account.get_fasjson") diff --git a/toddlers/utils/fedora_account.py b/toddlers/utils/fedora_account.py index f3d784a..7f4995e 100644 --- a/toddlers/utils/fedora_account.py +++ b/toddlers/utils/fedora_account.py @@ -101,7 +101,7 @@ def get_user_by_email(email: str) -> Optional[dict]: result = fasjson.search(email=email).result or [] if not result: # Try the bugzilla email as well - result = fasjson.search(rhbzemail=email).result or [] + result = fasjson.search(rhbzemail__exact=email).result or [] if result: user = result[0] except ClientError: