Skip to content

Commit

Permalink
Test new env var behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ClintonWB-EBSCO committed Oct 9, 2023
1 parent b58b82f commit c5ff0eb
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ def test_inheritance():

@mock.patch("getpass.getpass", create=True)
@mock.patch("builtins.input", create=True)
@mock.patch.dict(
"os.environ",
{},
)
def test_arg_prompts(insecure_inputs, secure_inputs):
secure_inputs.side_effect = ["okapi_password"]
insecure_inputs.side_effect = ["config_path", "task_name", "folder_path"]
args = __main__.parse_args([])
insecure_inputs.side_effect = ["folder_path"]
args = __main__.parse_args(["config_path", "task_name"])
assert args.__dict__ == {
"configuration_path": "config_path",
"task_name": "task_name",
Expand All @@ -36,6 +40,10 @@ def test_arg_prompts(insecure_inputs, secure_inputs):

@mock.patch("getpass.getpass", create=True)
@mock.patch("builtins.input", create=True)
@mock.patch.dict(
"os.environ",
{},
)
def test_args_positionally(insecure_inputs, secure_inputs):
args = __main__.parse_args(
[
Expand Down Expand Up @@ -111,3 +119,25 @@ def test_args_overriding_env(insecure_inputs, secure_inputs):
"okapi_password": "okapi_password",
"report_language": "fr",
}


@mock.patch("getpass.getpass", create=True)
@mock.patch("builtins.input", create=True)
@mock.patch.dict(
"os.environ",
{
"FOLIO_MIGRATION_TOOLS_CONFIGURATION_PATH": "config_path",
"FOLIO_MIGRATION_TOOLS_BASE_FOLDER_PATH": "folder_path",
"FOLIO_MIGRATION_TOOLS_OKAPI_PASSWORD": "okapi_password",
"FOLIO_MIGRATION_TOOLS_REPORT_LANGUAGE": "fr",
},
)
def test_task_name_arg_exception(insecure_inputs, secure_inputs):
args = __main__.parse_args(["task_name"])
assert args.__dict__ == {
"configuration_path": "config_path",
"task_name": "task_name",
"base_folder_path": "folder_path",
"okapi_password": "okapi_password",
"report_language": "fr",
}

0 comments on commit c5ff0eb

Please sign in to comment.