From 40b868cfee4d062ed0f98a6ceb5e0b484e4c0a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Mon, 2 Oct 2023 21:58:46 +0200 Subject: [PATCH] tests: multiple emails and phone_numbers --- demo/demoapp.py | 14 ++++++------- tests/backends/ldap/test_utils.py | 4 ++-- tests/backends/test_models.py | 24 +++++++++++----------- tests/conftest.py | 8 ++++---- tests/core/test_account.py | 12 +++++------ tests/core/test_groups.py | 4 ++-- tests/core/test_models.py | 2 +- tests/core/test_profile_settings.py | 8 ++++---- tests/oidc/test_authorization_code_flow.py | 4 ++-- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/demo/demoapp.py b/demo/demoapp.py index ebdaa020..0d42c38a 100644 --- a/demo/demoapp.py +++ b/demo/demoapp.py @@ -22,9 +22,9 @@ def populate(app): family_name="Doe", user_name="admin", display_name="Jane.D", - emails="admin@mydomain.tld", + emails=["admin@mydomain.tld"], password="admin", - phone_numbers="555-000-000", + phone_numbers=["555-000-000"], profile_url="https://admin.example", formatted_address="123, Admin Lane - Gotham City 12345", street="Admin Lane", @@ -42,9 +42,9 @@ def populate(app): family_name="Doe", user_name="moderator", display_name="👮 Jack 👮", - emails="moderator@mydomain.tld", + emails=["moderator@mydomain.tld"], password="moderator", - phone_numbers="555-000-002", + phone_numbers=["555-000-002"], profile_url="https://moderator.example", employee_number="1002", department_number="west", @@ -57,9 +57,9 @@ def populate(app): family_name="Doe", user_name="user", display_name="Johnny", - emails="user@mydomain.tld", + emails=["user@mydomain.tld"], password="user", - phone_numbers="555-000-001", + phone_numbers=["555-000-001"], profile_url="https://user.example", employee_number="1001", department_number="west", @@ -71,7 +71,7 @@ def populate(app): given_name="James", family_name="Doe", user_name="james", - emails="james@mydomain.tld", + emails=["james@mydomain.tld"], ) james.save() diff --git a/tests/backends/ldap/test_utils.py b/tests/backends/ldap/test_utils.py index 032eca0f..7b6a99f7 100644 --- a/tests/backends/ldap/test_utils.py +++ b/tests/backends/ldap/test_utils.py @@ -19,7 +19,7 @@ def test_object_creation(app, backend): formatted_name="Doe", # leading space family_name="Doe", user_name="user", - emails="john@doe.com", + emails=["john@doe.com"], ) assert not user.exists user.save() @@ -41,7 +41,7 @@ def test_dn_when_leading_space_in_id_attribute(testclient, backend): formatted_name=" Doe", # leading space family_name=" Doe", user_name=" user", - emails="john@doe.com", + emails=["john@doe.com"], ) user.save() diff --git a/tests/backends/test_models.py b/tests/backends/test_models.py index f8d14ec8..10bd6daa 100644 --- a/tests/backends/test_models.py +++ b/tests/backends/test_models.py @@ -135,34 +135,34 @@ def test_model_indexation(testclient, backend): assert models.User.get(family_name="family_name") == user assert not models.User.get(family_name="new_family_name") - assert models.User.get(emails="email1@user.com") == user - assert models.User.get(emails="email2@user.com") == user - assert not models.User.get(emails="email3@user.com") + assert models.User.get(emails=["email1@user.com"]) == user + assert models.User.get(emails=["email2@user.com"]) == user + assert not models.User.get(emails=["email3@user.com"]) user.family_name = "new_family_name" user.emails = ["email2@user.com"] assert models.User.get(family_name="family_name") != user assert not models.User.get(family_name="new_family_name") - assert models.User.get(emails="email1@user.com") != user - assert models.User.get(emails="email2@user.com") != user - assert not models.User.get(emails="email3@user.com") + assert models.User.get(emails=["email1@user.com"]) != user + assert models.User.get(emails=["email2@user.com"]) != user + assert not models.User.get(emails=["email3@user.com"]) user.save() assert not models.User.get(family_name="family_name") assert models.User.get(family_name="new_family_name") == user - assert not models.User.get(emails="email1@user.com") - assert models.User.get(emails="email2@user.com") == user - assert not models.User.get(emails="email3@user.com") + assert not models.User.get(emails=["email1@user.com"]) + assert models.User.get(emails=["email2@user.com"]) == user + assert not models.User.get(emails=["email3@user.com"]) user.delete() assert not models.User.get(family_name="family_name") assert not models.User.get(family_name="new_family_name") - assert not models.User.get(emails="email1@user.com") - assert not models.User.get(emails="email2@user.com") - assert not models.User.get(emails="email3@user.com") + assert not models.User.get(emails=["email1@user.com"]) + assert not models.User.get(emails=["email2@user.com"]) + assert not models.User.get(emails=["email3@user.com"]) def test_fuzzy(user, moderator, admin, backend): diff --git a/tests/conftest.py b/tests/conftest.py index 02c30c53..9d421492 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -142,11 +142,11 @@ def user(app, backend): given_name="John", family_name="Doe", user_name="user", - emails="john@doe.com", + emails=["john@doe.com"], password="correct horse battery staple", display_name="Johnny", preferred_language="en", - phone_numbers="555-000-000", + phone_numbers=["555-000-000"], profile_url="https://john.example", formatted_address="1235, somewhere", ) @@ -162,7 +162,7 @@ def admin(app, backend): formatted_name="Jane Doe", family_name="Doe", user_name="admin", - emails="jane@doe.com", + emails=["jane@doe.com"], password="admin", ) u.save() @@ -177,7 +177,7 @@ def moderator(app, backend): formatted_name="Jack Doe", family_name="Doe", user_name="moderator", - emails="jack@doe.com", + emails=["jack@doe.com"], password="moderator", ) u.save() diff --git a/tests/core/test_account.py b/tests/core/test_account.py index e6119c5a..abb34e6e 100644 --- a/tests/core/test_account.py +++ b/tests/core/test_account.py @@ -163,7 +163,7 @@ def test_first_login_account_initialization_mail_sending_failed( formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], ) u.save() @@ -185,7 +185,7 @@ def test_first_login_form_error(testclient, backend, smtpd): formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], ) u.save() @@ -207,7 +207,7 @@ def test_user_password_deleted_during_login(testclient, backend): formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], password="correct horse battery staple", ) u.save() @@ -231,7 +231,7 @@ def test_user_deleted_in_session(testclient, backend): formatted_name="Jake Doe", family_name="Jake", user_name="jake", - emails="jake@doe.com", + emails=["jake@doe.com"], password="correct horse battery staple", ) u.save() @@ -290,7 +290,7 @@ def test_admin_self_deletion(testclient, backend): formatted_name="Temp admin", family_name="admin", user_name="temp", - emails="temp@temp.com", + emails=["temp@temp.com"], password="admin", ) admin.save() @@ -316,7 +316,7 @@ def test_user_self_deletion(testclient, backend): formatted_name="Temp user", family_name="user", user_name="temp", - emails="temp@temp.com", + emails=["temp@temp.com"], password="correct horse battery staple", ) user.save() diff --git a/tests/core/test_groups.py b/tests/core/test_groups.py index f8dd6399..a6f42ea6 100644 --- a/tests/core/test_groups.py +++ b/tests/core/test_groups.py @@ -51,7 +51,7 @@ def test_group_deletion(testclient, backend): formatted_name="foobar", family_name="foobar", user_name="foobar", - emails="foo@bar.com", + emails=["foo@bar.com"], ) user.save() @@ -111,7 +111,7 @@ def test_set_groups_with_leading_space_in_user_id_attribute(app, foo_group): formatted_name=" Doe", # leading space in id attribute family_name="Doe", user_name="user2", - emails="john@doe.com", + emails=["john@doe.com"], ) user.save() diff --git a/tests/core/test_models.py b/tests/core/test_models.py index edcb4159..89ea3b90 100644 --- a/tests/core/test_models.py +++ b/tests/core/test_models.py @@ -32,7 +32,7 @@ def test_user_has_password(testclient, backend): formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], ) u.save() diff --git a/tests/core/test_profile_settings.py b/tests/core/test_profile_settings.py index 745eebd6..7732b76b 100644 --- a/tests/core/test_profile_settings.py +++ b/tests/core/test_profile_settings.py @@ -130,7 +130,7 @@ def test_password_initialization_mail(smtpd, testclient, backend, logged_admin): formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], ) u.save() @@ -166,7 +166,7 @@ def test_password_initialization_mail_send_fail( formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], ) u.save() @@ -236,7 +236,7 @@ def test_password_reset_email(smtpd, testclient, backend, logged_admin): formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], password="correct horse battery staple", ) u.save() @@ -264,7 +264,7 @@ def test_password_reset_email_failed(SMTP, smtpd, testclient, backend, logged_ad formatted_name="Temp User", family_name="Temp", user_name="temp", - emails="john@doe.com", + emails=["john@doe.com"], password=["correct horse battery staple"], ) u.save() diff --git a/tests/oidc/test_authorization_code_flow.py b/tests/oidc/test_authorization_code_flow.py index 846616e0..dafef4bc 100644 --- a/tests/oidc/test_authorization_code_flow.py +++ b/tests/oidc/test_authorization_code_flow.py @@ -826,7 +826,7 @@ def test_code_with_invalid_user(testclient, admin, client): formatted_name="John Doe", family_name="Doe", user_name="temp", - emails="temp@temp.com", + emails=["temp@temp.com"], password="correct horse battery staple", ) user.save() @@ -876,7 +876,7 @@ def test_refresh_token_with_invalid_user(testclient, client): formatted_name="John Doe", family_name="Doe", user_name="temp", - emails="temp@temp.com", + emails=["temp@temp.com"], password="correct horse battery staple", ) user.save()