Skip to content

Commit

Permalink
fixed skip if
Browse files Browse the repository at this point in the history
  • Loading branch information
chGoodchild committed Jan 28, 2022
1 parent d36aac3 commit 77a57c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
38 changes: 18 additions & 20 deletions test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def path_to_name(path):


def ifnone(var):
return (var == None) or (var == "")
return (var is None) or (var == "")


def get_files(file, expect=None):
Expand Down Expand Up @@ -177,31 +177,29 @@ def gha_credentials_dont_exist():
return user_not_set and pwd_not_set


def aws_credentials_exist():
sec_acc_key = ifnone("AWS_SECRET_ACCESS_KEY")
acc_key_id = ifnone("AWS_ACCESS_KEY_ID")
default_region = ifnone("AWS_DEFAULT_REGION")
def aws_credential_missing():
sec_acc_key = ifnone(os.environ.get("AWS_SECRET_ACCESS_KEY"))
acc_key_id = ifnone(os.environ.get("AWS_ACCESS_KEY_ID"))
default_region = ifnone(os.environ.get("AWS_DEFAULT_REGION"))
return sec_acc_key or acc_key_id or default_region


def aws_credentials_exist():
sec_access = not (
(os.environ.get("AWS_SECRET_ACCESS_KEY") is None)
or (os.environ.get("AWS_SECRET_ACCESS_KEY") == "")
)
access_id = not (
(os.environ.get("AWS_ACCESS_KEY_ID") is None)
or (os.environ.get("AWS_ACCESS_KEY_ID") == "")
)
default_region = not (
(os.environ.get("AWS_DEFAULT_REGION") is None)
or (os.environ.get("AWS_DEFAULT_REGION") == "")
)
return sec_access and access_id and default_region
def aws_credential_all_missing():
sec_acc_key = ifnone(os.environ.get("AWS_SECRET_ACCESS_KEY"))
acc_key_id = ifnone(os.environ.get("AWS_ACCESS_KEY_ID"))
default_region = ifnone(os.environ.get("AWS_DEFAULT_REGION"))
return sec_acc_key and acc_key_id and default_region


def aws_credentials_all_exist():
sec_acc_key = ifnone(os.environ.get("AWS_SECRET_ACCESS_KEY"))
acc_key_id = ifnone(os.environ.get("AWS_ACCESS_KEY_ID"))
default_region = ifnone(os.environ.get("AWS_DEFAULT_REGION"))
return not sec_acc_key and not acc_key_id and not default_region


skip_aws_credentials = pytest.mark.skipif(
not aws_credentials_exist(), reason="Not all AWS credentials are set"
aws_credential_missing(), reason="Not all AWS credentials are set"
)


Expand Down
4 changes: 2 additions & 2 deletions test/test_s3mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def mock_s3_minio(xprocess, file, fs_ready):
set_env_var(file, "AWS_ACCESS_KEY_ID")
set_env_var(file, "AWS_DEFAULT_REGION")

assert aws_credentials_exist() == True
assert aws_credentials_all_exist() == True

start_docker = [
"docker",
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_growing_file(
remote_zck_path = file["test_path"] / Path("conda_mock") / name
local_zck_path = file["tmp_path"] / name.name

assert aws_credentials_exist() == True
assert aws_credentials_all_exist() == True
remove_all(file)

content_present, gf = setup_file(
Expand Down
2 changes: 1 addition & 1 deletion test/test_s3server.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_growing_file(
remote_zck_path = file["test_path"] / Path("conda_mock") / name
local_zck_path = file["tmp_path"] / name.name

assert aws_credentials_exist() == True
assert aws_credentials_all_exist() == True
remove_all(file)

content_present, gf = setup_file(
Expand Down

0 comments on commit 77a57c1

Please sign in to comment.