Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit c739ae3

Browse files
committed
Add system tests
Signed-off-by: Andrew Ni <[email protected]>
1 parent c3e8d98 commit c739ae3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

system_tests/role_tests.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from click.testing import CliRunner
2+
3+
from pyvcloud.system_test_framework.base_test import BaseTestCase
4+
from pyvcloud.system_test_framework.environment import Environment
5+
from vcd_cli.login import login, logout
6+
from vcd_cli.role import role
7+
8+
DUMMY_ROLE_NAME = 'dummyrole'
9+
ORG_ADMIN_ROLE_NAME = 'Organization Administrator'
10+
11+
12+
class TestRole(BaseTestCase):
13+
"""Test Role related commands."""
14+
15+
def test_0000_setup(self):
16+
self._config = Environment.get_config()
17+
TestRole._logger = Environment.get_default_logger()
18+
TestRole._runner = CliRunner()
19+
self._login()
20+
21+
def _login(self):
22+
"""Logs in using admin credentials"""
23+
login_args = [
24+
self._config['vcd']['host'],
25+
self._config['vcd']['sys_org_name'],
26+
self._config['vcd']['sys_admin_username'],
27+
"-i",
28+
"-w",
29+
f"--password={self._config['vcd']['sys_admin_pass']}"
30+
]
31+
result = TestRole._runner.invoke(login, args=login_args)
32+
self.assertEqual(0, result.exit_code)
33+
self.assertTrue("logged in" in result.output)
34+
35+
def test_0010_role_clone(self):
36+
# org admin and sys admin can clone roles
37+
result = self._runner.invoke(
38+
role,
39+
args=['clone', ORG_ADMIN_ROLE_NAME, DUMMY_ROLE_NAME])
40+
TestRole._logger.debug(f"vcd role clone {ORG_ADMIN_ROLE_NAME} "
41+
f"{DUMMY_ROLE_NAME}: {result.output}")
42+
self.assertEqual(0, result.exit_code)
43+
44+
def test_9999_teardown(self):
45+
TestRole._runner.invoke(logout)

0 commit comments

Comments
 (0)