-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd28ca6
commit a1b8c31
Showing
1 changed file
with
1 addition
and
39 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -101,10 +101,8 @@ def mock_query_ldap( | |
|
||
|
||
@pytest.mark.usefixtures("empty_read_write_db") | ||
def test_acquire_users_prompt(cli_main, monkeypatch): | ||
def test_acquire_users_prompt(cli_main, monkeypatch, mock_file): | ||
"""Test command line `sarc acquire users --prompt`.""" | ||
|
||
cfg = config() | ||
nbr_users = 10 | ||
|
||
def mock_query_ldap( | ||
|
@@ -115,42 +113,6 @@ def mock_query_ldap( | |
|
||
monkeypatch.setattr(sarc.ldap.read_mila_ldap, "query_ldap", mock_query_ldap) | ||
|
||
file1_content = """"Status","Username","Nom","Email","État du compte" | ||
"Activated","john.smith000","John Smith the 000rd","[email protected]","activé" | ||
"Activated","john.smith001","John Smith the 001rd","[email protected]","activé" | ||
"Activated","john.smith002","John Smith the 002rd","[email protected]","activé" | ||
"Activated","stranger.person","Mysterious Stranger","[email protected]","activé" | ||
""" | ||
file2_content = """Name,Sponsor,Permission,Activation_Status,username,Email | ||
John Smith the 000rd,BigProf,Manager,activated,john.smith000,[email protected] | ||
John Smith the 001rd,BigProf,Manager,activated,john.smith001,[email protected] | ||
John Smith the 002rd,BigProf,Manager,activated,john.smith002,[email protected] | ||
Mysterious Stranger,BigProf,Manager,activated,stranger.person,[email protected] | ||
""" | ||
file3_content = """{ | ||
"L_phantom_mila_emails_to_ignore": | ||
[ | ||
"[email protected]" | ||
], | ||
"D_override_matches_mila_to_cc_account_username": | ||
{ | ||
"[email protected]": "js_the_first" | ||
} | ||
} | ||
""" | ||
|
||
file_contents = { | ||
cfg.account_matching.drac_roles_csv_path: file1_content, | ||
cfg.account_matching.drac_members_csv_path: file2_content, | ||
cfg.account_matching.make_matches_config: file3_content, | ||
} | ||
|
||
def mock_file(filename, *vargs, **kwargs): | ||
if filename in file_contents: | ||
return mock_open(read_data=file_contents[filename]).return_value | ||
else: | ||
raise FileNotFoundError(filename) | ||
|
||
# Feed input for prompt. | ||
# First input firstly receives `a` (invalid, should re-prompt) | ||
# then <enter> (valid, ignore). | ||
|