Skip to content

Commit

Permalink
Fix unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
notoraptor committed Jul 20, 2023
1 parent fd28ca6 commit a1b8c31
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions tests/functional/cli/acquire/test_acquire_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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).
Expand Down

0 comments on commit a1b8c31

Please sign in to comment.