Skip to content

Commit ea87682

Browse files
committed
refactor test
Signed-off-by: Chris Snow <[email protected]>
1 parent 4ace9f1 commit ea87682

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

DEVELOPING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ tox -e py27 -- tests/library/client_test.py:TestCreateFromProperties.test_create
110110
Aim for 100% test coverage to ensure library will work with all specified python versions.
111111

112112
```
113-
coverage erase && coverage run --source hpecp setup.py test && coverage report -m
113+
coverage erase && coverage run --source hpecp,bin setup.py test && coverage report -m
114114
```
115115

116116

tests/cli/cli_test.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ def mocked_requests_get(*args, **kwargs):
120120
)
121121
raise RuntimeError("Unhandle GET request: " + args[0])
122122

123-
@patch("requests.post", side_effect=mocked_requests_post)
124-
@patch("requests.get", side_effect=mocked_requests_get)
125-
def test_example(self, mock_post, mock_get):
126-
123+
def setUp(self):
127124
file_data = dedent(
128125
"""[default]
129126
api_host = 127.0.0.1
@@ -135,17 +132,29 @@ def test_example(self, mock_post, mock_get):
135132
password = admin123"""
136133
)
137134

138-
tmp = tempfile.NamedTemporaryFile(delete=True)
139-
try:
140-
tmp.write(file_data.encode("utf-8"))
141-
tmp.flush()
135+
self.tmpFile = tempfile.NamedTemporaryFile(delete=True)
136+
self.tmpFile.write(file_data.encode("utf-8"))
137+
self.tmpFile.flush()
138+
139+
sys.path.insert(0, os.path.abspath("../../"))
140+
from bin import cli
141+
142+
self.cli = cli
143+
self.cli.HPECP_CONFIG_FILE = self.tmpFile.name
142144

143-
cli.HPECP_CONFIG_FILE = tmp.name
145+
def tearDown(self):
146+
self.tmpFile.close()
144147

145-
hpecp = cli.CLI()
146-
hpecp.k8scluster.list()
148+
def test_autocomplete_bash(self):
149+
150+
hpecp = self.cli.CLI()
151+
hpecp.autocomplete.bash()
152+
153+
# TODO move this to tests/library/k8s_cluster_test.py
154+
@patch("requests.post", side_effect=mocked_requests_post)
155+
@patch("requests.get", side_effect=mocked_requests_get)
156+
def test_k8scluster_list(self, mock_post, mock_get):
147157

148-
self.assertTrue(True)
158+
hpecp = self.cli.CLI()
159+
hpecp.k8scluster.list()
149160

150-
finally:
151-
tmp.close()

0 commit comments

Comments
 (0)