-
Notifications
You must be signed in to change notification settings - Fork 4
SARC-292 SARC-293 users exceptions #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2b65404
fix conftest to comply to exception implementation in sarc/ldap/super…
nurbal 9433bcc
conftest exception for delegations and supervisors overrides
nurbal 0b5763b
test for supervisors overrides
nurbal 8b5d2b8
supervisors override implementation
nurbal 9f0f418
add teacher_delegations in User API
nurbal c69a338
add test for teacher_delegations + lint
nurbal e7f3393
remove print
nurbal 2418574
add teachers delegations implementation
nurbal abc367b
fix tests made without exceptions file
nurbal f206155
lint
nurbal 10a720a
fix test_query_to_ldap_server_and_writing_to_output_json (ignore co_s…
nurbal 8cef544
Merge commit 'be44d1a5f2ee0ed5bac764009e8d3ed87518cd2a' into users_ex…
nurbal 9d61cb4
updated test_acquire_users_supervisors and test_acquire_users_co_supe…
nurbal 7469517
lint/black/whatever
nurbal a95b9e7
Merge branch 'master' into users_exceptions
nurbal 627f9d6
lint
nurbal 9249978
Move the supervisors override and prof delegation exceptions to sarc.…
nurbal de015ae
Merge branch 'master' into users_exceptions
nurbal ad9f863
Merge branch 'master' into users_exceptions
nurbal 56eb39c
fix test `test_load_job_series_with_users` to include the new `teache…
nurbal 0329790
Merge branch 'master' into users_exceptions
nurbal 8644834
Merge commit 'bab50a574ce25cf52ccf45fcd8aa4638f14da6c0' into users_ex…
nurbal a32536f
lint
nurbal ce1523d
fix tests: `test_get_user` and `test_get_users`
nurbal b945460
update lint exceptions ( disable too-many-positional-arguments )
nurbal 59cab5f
fix test `test_acquire_ldap_revision_change`
nurbal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,8 +180,24 @@ def file_contents(): | |
| """ | ||
| exceptions_json_path = """ | ||
| { | ||
| "not_prof": [], | ||
| "not_student": [] | ||
| "not_teacher": [], | ||
| "not_student": [], | ||
| "delegations": { | ||
| "[email protected]": [ | ||
| "[email protected]", | ||
| "[email protected]" | ||
| ] | ||
| }, | ||
| "supervisors_overrides": { | ||
| "[email protected]": [ | ||
| "[email protected]" | ||
| ], | ||
| "[email protected]": [ | ||
| "[email protected]", | ||
| "[email protected]" | ||
| ] | ||
| } | ||
|
|
||
| } | ||
| """ | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,37 @@ def mock_query_ldap( | |
| js_user = get_user(drac_account_username="stranger.person") | ||
| assert js_user is None | ||
|
|
||
| # test supervisor overrides | ||
| js_user = get_user(mila_email_username="[email protected]") | ||
| assert js_user is not None | ||
| assert js_user.mila_ldap["supervisor"] == "[email protected]" | ||
| assert js_user.mila_ldap["co_supervisor"] == None | ||
|
|
||
| js_user = get_user(mila_email_username="[email protected]") | ||
| assert js_user is not None | ||
| assert js_user.mila_ldap["supervisor"] == "[email protected]" | ||
| assert js_user.mila_ldap["co_supervisor"] == "[email protected]" | ||
|
|
||
| # test delegations | ||
| # john.smith003 should have delegations for john.smith004 and john.smith005 | ||
| # john.smith004 should have no delegations | ||
| # john.smith005 should have no delegations | ||
|
|
||
| js_user = get_user(mila_email_username="[email protected]") | ||
| assert js_user is not None | ||
| assert js_user.teacher_delegations is not None | ||
| assert "[email protected]" in js_user.teacher_delegations | ||
| assert "[email protected]" in js_user.teacher_delegations | ||
| assert "[email protected]" not in js_user.teacher_delegations | ||
|
|
||
| js_user = get_user(mila_email_username="[email protected]") | ||
| assert js_user is not None | ||
| assert js_user.teacher_delegations == None | ||
|
|
||
| js_user = get_user(mila_email_username="[email protected]") | ||
| assert js_user is not None | ||
| assert js_user.teacher_delegations == None | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "ldap_supervisor,mymila_supervisor,expected_supervisor", | ||
|
|
@@ -163,6 +194,10 @@ def test_acquire_users_supervisors( | |
| nbr_users = 4 | ||
| nbr_profs = 2 | ||
|
|
||
| # for the test we will use the user with index 3, | ||
| # which is the first user who has no supervisor override in the mock data | ||
| # so that this test won't be affected by the previous test | ||
|
|
||
| # Mock the fake LDAP data used for the tests | ||
| def mock_query_ldap( | ||
| local_private_key_file, local_certificate_file, ldap_service_uri | ||
|
|
@@ -171,7 +206,7 @@ def mock_query_ldap( | |
| return fake_raw_ldap_data( | ||
| nbr_users, | ||
| hardcoded_values_by_user={ | ||
| 2: { # The first user who is not a prof is the one with index 2 | ||
| 3: { # The first user who is not a prof is the one with index 3 | ||
| "supervisor": ldap_supervisor | ||
| } | ||
| }, | ||
|
|
@@ -185,7 +220,7 @@ def mock_query_mymila(tmp_json_path): | |
| nbr_users=nbr_users, | ||
| nbr_profs=nbr_profs, | ||
| hardcoded_values_by_user={ | ||
| 2: { # The first user who is not a prof is the one with index 2 | ||
| 3: { # The first user who is not a prof is the one with index 3 | ||
| "Supervisor Principal": mymila_supervisor | ||
| } | ||
| }, | ||
|
|
@@ -208,8 +243,8 @@ def mock_query_mymila(tmp_json_path): | |
|
|
||
| # Validate the results of all of this by inspecting the database. | ||
| js_user = get_user( | ||
| mila_email_username=f"john.smith002@mila.quebec" | ||
| ) # We modified the user with index 2; thus this is the one we retrieve | ||
| mila_email_username=f"john.smith003@mila.quebec" | ||
| ) # We modified the user with index 3; thus this is the one we retrieve | ||
| assert js_user.mila_ldap["supervisor"] == expected_supervisor | ||
|
|
||
|
|
||
|
|
@@ -255,6 +290,10 @@ def test_acquire_users_co_supervisors( | |
| nbr_users = 4 | ||
| nbr_profs = 2 | ||
|
|
||
| # for the test we will use the user with index 3, | ||
| # which is the first user who has no supervisor override in the mock data | ||
| # so that this test won't be affected by the previous test | ||
|
|
||
| # Mock the fake LDAP data used for the tests | ||
| def mock_query_ldap( | ||
| local_private_key_file, local_certificate_file, ldap_service_uri | ||
|
|
@@ -263,7 +302,7 @@ def mock_query_ldap( | |
| return fake_raw_ldap_data( | ||
| nbr_users, | ||
| hardcoded_values_by_user={ | ||
| 2: { # The first user who is not a prof is the one with index 2 | ||
| 3: { # The first user who is not a prof is the one with index 3 | ||
| "co_supervisor": ldap_co_supervisor | ||
| } | ||
| }, | ||
|
|
@@ -277,7 +316,7 @@ def mock_query_mymila(tmp_json_path): | |
| nbr_users=nbr_users, | ||
| nbr_profs=nbr_profs, | ||
| hardcoded_values_by_user={ | ||
| 2: { # The first user who is not a prof is the one with index 2 | ||
| 3: { # The first user who is not a prof is the one with index 3 | ||
| "Co-Supervisor": mymila_co_supervisor | ||
| } | ||
| }, | ||
|
|
@@ -300,8 +339,8 @@ def mock_query_mymila(tmp_json_path): | |
|
|
||
| # Validate the results of all of this by inspecting the database. | ||
| js_user = get_user( | ||
| mila_email_username=f"john.smith002@mila.quebec" | ||
| ) # We modified the user with index 2; thus this is the one we retrieve | ||
| mila_email_username=f"john.smith003@mila.quebec" | ||
| ) # We modified the user with index 3; thus this is the one we retrieve | ||
| assert js_user.mila_ldap["co_supervisor"] == expected_co_supervisor | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On essaie de partitionner chaque phase de chargement pour pouvoir les convertir en module avec une interface générique. Par exemple, le code de la ligne 35 https://github.com/mila-iqia/SARC/pull/103/files#diff-e9c775d5112b754dc796c041cfd42e5feddc9419366751fe3e0ffa2b9a025a73R35 aurait du se retoruver dans
fetch_mymila.Ces exceptions sont surtout en lien avec mymila, je crois que ça devrait aussi être dans
fetch_mymila.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En l'occurrence, pas tout à fait. Pour les exceptions de superviseurs, OUI c'est en lien avec MyMila. Par contre pour les délégations de supervision, NON cette info n'est pas présente dans les 3 sources de données (DRAC, LDAP et MyMila) donc elles ont un scope "général".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce que je veux dire, c'est que ces exceptions sont appliquées après le matching des 3 sources de données, indépendemment de la provenance des valeurs des champs concernés. Elles sont "agnostiques" si on veut...
Ça me paraissait donc logique de les appliquer à ce niveau là.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, donc dans un soucis de rendre ça le plus générique possible, ça serait comme un module supplémentaire dans le pipeline qui ajoute des corrections aux sources précédentes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fxed in 9249978