From 6de8f101273594aa15d7a799e406eddf72b1fdf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 19 Mar 2024 17:36:30 +0100 Subject: [PATCH] tests: adjust users datasources to check against correct id (#88364) --- tests/test_datasource_users.py | 114 ++++++++++++++++----------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/tests/test_datasource_users.py b/tests/test_datasource_users.py index 3bce97a3a..713c57b41 100644 --- a/tests/test_datasource_users.py +++ b/tests/test_datasource_users.py @@ -59,11 +59,11 @@ def test_datasource_users(pub): assert data_sources.get_items({'type': datasource.slug}) == [ ( - '1', + str(users[0].id), 'John Doe 0', - '1', + str(users[0].id), { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -74,11 +74,11 @@ def test_datasource_users(pub): }, ), ( - '2', + str(users[1].id), 'John Doe 1', - '2', + str(users[1].id), { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -91,11 +91,11 @@ def test_datasource_users(pub): ] assert data_sources.get_items(datasource.extended_data_source) == [ ( - '1', + str(users[0].id), 'John Doe 0', - '1', + str(users[0].id), { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -106,11 +106,11 @@ def test_datasource_users(pub): }, ), ( - '2', + str(users[1].id), 'John Doe 1', - '2', + str(users[1].id), { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -123,7 +123,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -133,7 +133,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -145,7 +145,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -155,7 +155,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -171,7 +171,7 @@ def test_datasource_users(pub): datasource.store() assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -181,7 +181,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -193,7 +193,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -203,7 +203,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -225,7 +225,7 @@ def test_datasource_users(pub): users[0].store() assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -237,7 +237,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -256,7 +256,7 @@ def test_datasource_users(pub): datasource.store() assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -268,7 +268,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -293,7 +293,7 @@ def test_datasource_users(pub): assert not datasource.include_disabled_users assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -305,7 +305,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -321,7 +321,7 @@ def test_datasource_users(pub): datasource.store() assert data_sources.get_structured_items({'type': datasource.slug}) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -331,7 +331,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -343,7 +343,7 @@ def test_datasource_users(pub): ] assert data_sources.get_structured_items(datasource.extended_data_source) == [ { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -353,7 +353,7 @@ def test_datasource_users(pub): 'user_email': None, }, { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -367,7 +367,7 @@ def test_datasource_users(pub): # by uuid assert datasource.get_structured_value('abc0') == { - 'id': 1, + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -378,7 +378,7 @@ def test_datasource_users(pub): } assert datasource.get_display_value('abc0') == 'John Doe 0' assert datasource.get_structured_value('abc1') == { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -390,8 +390,8 @@ def test_datasource_users(pub): assert datasource.get_display_value('abc1') == 'John Doe 1' # by id - assert datasource.get_structured_value('1') == { - 'id': 1, + assert datasource.get_structured_value(str(users[0].id)) == { + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -400,9 +400,9 @@ def test_datasource_users(pub): 'user_display_name': 'John Doe 0', 'user_email': None, } - assert datasource.get_display_value('1') == 'John Doe 0' - assert datasource.get_structured_value('2') == { - 'id': 2, + assert datasource.get_display_value(str(users[0].id)) == 'John Doe 0' + assert datasource.get_structured_value(str(users[1].id)) == { + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -411,11 +411,11 @@ def test_datasource_users(pub): 'user_display_name': 'John Doe 1', 'user_email': None, } - assert datasource.get_display_value('2') == 'John Doe 1' + assert datasource.get_display_value(str(users[1].id)) == 'John Doe 1' # by numeric id - assert datasource.get_structured_value(1) == { - 'id': 1, + assert datasource.get_structured_value(users[0].id) == { + 'id': users[0].id, 'text': 'John Doe 0', 'user_name_identifier_0': 'abc0', 'user_nameid': 'abc0', @@ -424,9 +424,9 @@ def test_datasource_users(pub): 'user_display_name': 'John Doe 0', 'user_email': None, } - assert datasource.get_display_value(1) == 'John Doe 0' - assert datasource.get_structured_value(2) == { - 'id': 2, + assert datasource.get_display_value(users[0].id) == 'John Doe 0' + assert datasource.get_structured_value(users[1].id) == { + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -435,7 +435,7 @@ def test_datasource_users(pub): 'user_display_name': 'John Doe 1', 'user_email': None, } - assert datasource.get_display_value(2) == 'John Doe 1' + assert datasource.get_display_value(users[1].id) == 'John Doe 1' datasource.users_included_roles = [role1.id] datasource.users_excluded_roles = [role2.id] @@ -447,7 +447,7 @@ def test_datasource_users(pub): assert datasource.get_structured_value('abc0') is None assert datasource.get_display_value('abc0') is None assert datasource.get_structured_value('abc1') == { - 'id': 2, + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -459,10 +459,10 @@ def test_datasource_users(pub): assert datasource.get_display_value('abc1') == 'John Doe 1' # by id - assert datasource.get_structured_value('1') is None - assert datasource.get_display_value('1') is None - assert datasource.get_structured_value('2') == { - 'id': 2, + assert datasource.get_structured_value(str(users[0].id)) is None + assert datasource.get_display_value(str(users[0].id)) is None + assert datasource.get_structured_value(str(users[1].id)) == { + 'id': users[1].id, 'text': 'John Doe 1', 'user_name_identifier_0': 'abc1', 'user_nameid': 'abc1', @@ -471,7 +471,7 @@ def test_datasource_users(pub): 'user_display_name': 'John Doe 1', 'user_email': None, } - assert datasource.get_display_value('2') == 'John Doe 1' + assert datasource.get_display_value(str(users[1].id)) == 'John Doe 1' datasource.include_disabled_users = False datasource.store() @@ -485,10 +485,10 @@ def test_datasource_users(pub): assert datasource.get_display_value('abc1') is None # by id - assert datasource.get_structured_value('1') is None - assert datasource.get_display_value('1') is None - assert datasource.get_structured_value('2') is None - assert datasource.get_display_value('2') is None + assert datasource.get_structured_value(str(users[0].id)) is None + assert datasource.get_display_value(str(users[0].id)) is None + assert datasource.get_structured_value(str(users[1].id)) is None + assert datasource.get_display_value(str(users[1].id)) is None def test_datasource_users_user_formdef(pub): @@ -511,9 +511,9 @@ def test_datasource_users_user_formdef(pub): assert data_sources.get_items({'type': datasource.slug}) == [ ( - '3', + str(user.id), 'John Doe', - '3', + str(user.id), { 'user_display_name': 'John Doe', 'user_email': None, @@ -522,7 +522,7 @@ def test_datasource_users_user_formdef(pub): 'user_var_plop': 'Bar', 'user_admin_access': False, 'user_backoffice_access': False, - 'id': 3, + 'id': user.id, 'text': 'John Doe', }, )