Python CSC Electronic Office
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
pyceo/tests/ceo/cli/test_cloud.py

54 lines
1.7 KiB

from click.testing import CliRunner
from ...utils import gssapi_token_ctx
from ceo.cli import cli
def test_cloud_account_activate(cli_setup, mock_cloud_server, new_user, cfg):
base_domain = cfg.get('base_domain')
mock_cloud_server.clear()
runner = CliRunner()
with gssapi_token_ctx(new_user.uid):
result = runner.invoke(cli, ['cloud', 'account', 'activate'])
expected = (
'Congratulations! Your cloud account has been activated.\n'
f'You may now login into https://cloud.{base_domain} with your CSC credentials.\n'
"Make sure to enter 'Members' for the domain (no quotes).\n"
)
assert result.exit_code == 0
assert result.output == expected
def test_cloud_accounts_purge(cli_setup, mock_cloud_server):
mock_cloud_server.clear()
runner = CliRunner()
result = runner.invoke(cli, ['cloud', 'accounts', 'purge'])
assert result.exit_code == 0
def test_cloud_vhosts(cli_setup, new_user, cfg):
members_domain = cfg.get('cloud vhosts_members_domain')
uid = new_user.uid
domain1 = uid + '.' + members_domain
ip1 = '172.19.134.11'
runner = CliRunner()
with gssapi_token_ctx(uid):
result = runner.invoke(cli, ['cloud', 'vhosts', 'add', domain1, ip1])
expected = 'Done.\n'
assert result.exit_code == 0
assert result.output == expected
with gssapi_token_ctx(uid):
result = runner.invoke(cli, ['cloud', 'vhosts', 'list'])
expected = domain1 + ': ' + ip1 + '\n'
assert result.exit_code == 0
assert result.output == expected
with gssapi_token_ctx(uid):
result = runner.invoke(cli, ['cloud', 'vhosts', 'delete', domain1])
expected = 'Done.\n'
assert result.exit_code == 0
assert result.output == expected