-
Notifications
You must be signed in to change notification settings - Fork 161
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
Showing
1 changed file
with
41 additions
and
36 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
from dlt.cli.exceptions import CliCommandInnerException | ||
from dlt.pipeline.exceptions import CannotRestorePipelineException | ||
from dlt.cli.deploy_command_helpers import get_schedule_description | ||
from dlt.cli.exceptions import CliCommandException | ||
|
||
from tests.utils import TEST_STORAGE_ROOT, reset_providers, test_storage | ||
|
||
|
@@ -47,13 +48,14 @@ def test_deploy_command_no_repo( | |
) | ||
|
||
# test wrapper | ||
rc = _dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert rc == -3 | ||
with pytest.raises(CliCommandException) as ex: | ||
_dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert ex._excinfo[1].error_code == -4 | ||
|
||
|
||
@pytest.mark.parametrize("deployment_method,deployment_args", DEPLOY_PARAMS) | ||
|
@@ -80,13 +82,13 @@ def test_deploy_command( | |
**deployment_args | ||
) | ||
assert "Your current repository has no origin set" in py_ex.value.args[0] | ||
rc = _dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert rc == -5 | ||
with pytest.raises(CliCommandInnerException): | ||
_dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
|
||
# we have a repo that was never run | ||
Remote.create(repo, "origin", "[email protected]:rudolfix/dlt-cmd-test-2.git") | ||
|
@@ -97,18 +99,19 @@ def test_deploy_command( | |
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
rc = _dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert rc == -2 | ||
with pytest.raises(CliCommandException) as ex: | ||
rc = _dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert ex._excinfo[1].error_code == -3 | ||
|
||
# run the script with wrong credentials (it is postgres there) | ||
venv = Venv.restore_current() | ||
# mod environ so wrong password is passed to override secrets.toml | ||
pg_credentials = os.environ.pop("DESTINATION__POSTGRES__CREDENTIALS") | ||
pg_credentials = os.environ.pop("DESTINATION__POSTGRES__CREDENTIALS", "") | ||
# os.environ["DESTINATION__POSTGRES__CREDENTIALS__PASSWORD"] = "password" | ||
with pytest.raises(CalledProcessError): | ||
venv.run_script("debug_pipeline.py") | ||
|
@@ -121,13 +124,14 @@ def test_deploy_command( | |
**deployment_args | ||
) | ||
assert "The last pipeline run ended with error" in py_ex2.value.args[0] | ||
rc = _dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert rc == -2 | ||
with pytest.raises(CliCommandException) as ex: | ||
_dlt.deploy_command_wrapper( | ||
"debug_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert ex._excinfo[1].error_code == -3 | ||
|
||
os.environ["DESTINATION__POSTGRES__CREDENTIALS"] = pg_credentials | ||
# also delete secrets so credentials are not mixed up on CI | ||
|
@@ -172,10 +176,11 @@ def test_deploy_command( | |
**deployment_args | ||
) | ||
with echo.always_choose(False, always_choose_value=True): | ||
rc = _dlt.deploy_command_wrapper( | ||
"no_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert rc == -4 | ||
with pytest.raises(CliCommandException) as ex: | ||
_dlt.deploy_command_wrapper( | ||
"no_pipeline.py", | ||
deployment_method, | ||
deploy_command.COMMAND_DEPLOY_REPO_LOCATION, | ||
**deployment_args | ||
) | ||
assert ex._excinfo[0].error_code == -5 |