Skip to content

Commit aebbb5c

Browse files
authored
Merge pull request #589 from neuroinformatics-unit/skip_aws_gdrive_tests
Skip AWS and GDRIVE tests when environment variables not set.
2 parents b4851cb + b7e4708 commit aebbb5c

File tree

10 files changed

+58
-13
lines changed

10 files changed

+58
-13
lines changed

.github/workflows/code_test_and_deploy.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,6 @@ jobs:
8787
pytest tests/tests_transfers/aws
8888
8989
- name: All Other Tests
90-
env:
91-
GDRIVE_CLIENT_ID: ${{ secrets.GDRIVE_CLIENT_ID }}
92-
GDRIVE_CLIENT_SECRET: ${{ secrets.GDRIVE_CLIENT_SECRET }}
93-
GDRIVE_ROOT_FOLDER_ID: ${{ secrets.GDRIVE_ROOT_FOLDER_ID }}
94-
GDRIVE_CONFIG_TOKEN: ${{ secrets.GDRIVE_CONFIG_TOKEN }}
95-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
96-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
97-
AWS_REGION: ${{ secrets.AWS_REGION }}
98-
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
9990
run: |
10091
pytest --ignore=tests/tests_transfers/ssh --ignore=tests/tests_transfers/gdrive --ignore=tests/tests_transfers/aws
10192

tests/tests_transfers/aws/aws_test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ def setup_aws_connection(project: DataShuttle):
4242
project.setup_aws_connection()
4343

4444
aws.get_aws_secret_access_key = original_get_secret
45+
46+
47+
def has_aws_environment_variables():
48+
for key in [
49+
"AWS_BUCKET_NAME",
50+
"AWS_ACCESS_KEY_ID",
51+
"AWS_REGION",
52+
"AWS_SECRET_ACCESS_KEY",
53+
]:
54+
if key not in os.environ:
55+
return False
56+
return True

tests/tests_transfers/aws/test_aws_transfer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from . import aws_test_utils
77

88

9+
@pytest.mark.skipif(
10+
not aws_test_utils.has_aws_environment_variables(),
11+
reason="AWS set up environment variables must be set.",
12+
)
913
class TestAwsTransfer(BaseTransfer):
1014
@pytest.fixture(
1115
scope="class",

tests/tests_tui/aws/test_tui_setup_aws.py renamed to tests/tests_transfers/aws/test_tui_setup_aws.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66
from datashuttle.tui.screens.project_manager import ProjectManagerScreen
77
from datashuttle.utils import rclone, utils
88

9-
from ..tui_base import TuiBase
9+
from ...tests_tui.tui_base import TuiBase
10+
from . import aws_test_utils
1011

1112

13+
@pytest.mark.skipif(
14+
not aws_test_utils.has_aws_environment_variables(),
15+
reason="AWS set up environment variables must be set.",
16+
)
1217
class TestTuiSetupAws(TuiBase):
18+
"""
19+
Set up the connection to AWS via the TUI. These tests require
20+
environment variables to be set to allow the full set up,
21+
like other transfer tests.
22+
"""
23+
1324
@pytest.fixture(scope="function")
1425
def central_path_and_project(self, setup_project_paths):
1526
tmp_config_path, tmp_path, project_name = setup_project_paths.values()

tests/tests_transfers/gdrive/gdrive_test_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ def mock_input(_: str) -> str:
5656

5757
builtins.input = original_input
5858
gdrive.get_client_secret = original_get_secret
59+
60+
61+
def has_gdrive_environment_variables():
62+
for key in [
63+
"GDRIVE_CLIENT_ID",
64+
"GDRIVE_ROOT_FOLDER_ID",
65+
"GDRIVE_CONFIG_TOKEN",
66+
"GDRIVE_CLIENT_SECRET",
67+
]:
68+
if key not in os.environ:
69+
return False
70+
return True

tests/tests_transfers/gdrive/test_gdrive_transfer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from . import gdrive_test_utils
77

88

9+
@pytest.mark.skipif(
10+
not gdrive_test_utils.has_gdrive_environment_variables(),
11+
reason="Google Drive set up environment variables must be set.",
12+
)
913
class TestGdriveTransfer(BaseTransfer):
1014
@pytest.fixture(
1115
scope="class",

tests/tests_tui/gdrive/test_tui_setup_gdrive.py renamed to tests/tests_transfers/gdrive/test_tui_setup_gdrive.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@
77
from datashuttle.utils import rclone, utils
88

99
from ... import test_utils
10-
from ..tui_base import TuiBase
10+
from ...tests_tui.tui_base import TuiBase
11+
from . import gdrive_test_utils
1112

1213

14+
@pytest.mark.skipif(
15+
not gdrive_test_utils.has_gdrive_environment_variables(),
16+
reason="Google Drive set up environment variables must be set.",
17+
)
1318
class TestTuiSetupGdrive(TuiBase):
19+
"""
20+
Set up the connection to GDrive via the TUI. These tests require
21+
environment variables to be set to allow the full set up,
22+
like other transfer tests.
23+
"""
24+
1425
@pytest.fixture(scope="function")
1526
def central_path_and_project(self, setup_project_paths):
1627
tmp_config_path, tmp_path, project_name = setup_project_paths.values()

tests/tests_tui/gdrive/__init__.py

Whitespace-only changes.

tests/tests_tui/aws/test_tui_aws_configs.py renamed to tests/tests_tui/test_tui_aws_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from datashuttle.tui.app import TuiApp
66

7-
from ..tui_configs_base import TuiConfigsBase
7+
from .tui_configs_base import TuiConfigsBase
88

99

1010
class TestTuiAwsConfigs(TuiConfigsBase):

tests/tests_tui/gdrive/test_tui_gdrive_configs.py renamed to tests/tests_tui/test_tui_gdrive_configs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from datashuttle.tui.app import TuiApp
66

7-
from ..tui_configs_base import TuiConfigsBase
7+
from .tui_configs_base import TuiConfigsBase
88

99

1010
class TestTuiGdriveConfigs(TuiConfigsBase):

0 commit comments

Comments
 (0)