Skip to content

Commit fe12dad

Browse files
committed
Separate check_resource inspect tests
1 parent 9cdf1dc commit fe12dad

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

tests/test.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,18 +1781,21 @@ def test_inspect_container(self):
17811781
self.client.inspect_container(fake_api.FAKE_CONTAINER_ID)
17821782
except Exception as e:
17831783
self.fail('Command should not raise exception: {0}'.format(e))
1784-
1785-
try:
1786-
self.client.inspect_container('')
1787-
except ValueError as e:
1788-
self.assertEqual(e.args[0],
1789-
'image or container param is empty')
1790-
17911784
fake_request.assert_called_with(
17921785
url_prefix + 'containers/3cc2351ab11b/json',
17931786
timeout=DEFAULT_TIMEOUT_SECONDS
17941787
)
17951788

1789+
def test_inspect_container_empty_id(self):
1790+
try:
1791+
self.client.inspect_container('')
1792+
except docker.errors.NullResource as e:
1793+
self.assertEqual(
1794+
e.args[0], 'image or container param is undefined'
1795+
)
1796+
else:
1797+
self.fail('Command expected NullResource exception')
1798+
17961799
def test_container_stats(self):
17971800
try:
17981801
self.client.stats(fake_api.FAKE_CONTAINER_ID)
@@ -1959,17 +1962,21 @@ def test_inspect_image(self):
19591962
except Exception as e:
19601963
self.fail('Command should not raise exception: {0}'.format(e))
19611964

1962-
try:
1963-
self.client.inspect_image('')
1964-
except ValueError as e:
1965-
self.assertEqual(e.args[0],
1966-
'image or container param is empty')
1967-
19681965
fake_request.assert_called_with(
19691966
url_prefix + 'images/test_image/json',
19701967
timeout=DEFAULT_TIMEOUT_SECONDS
19711968
)
19721969

1970+
def test_inspect_image_empty_id(self):
1971+
try:
1972+
self.client.inspect_image('')
1973+
except docker.errors.NullResource as e:
1974+
self.assertEqual(
1975+
e.args[0], 'image or container param is undefined'
1976+
)
1977+
else:
1978+
self.fail('Command expected NullResource exception')
1979+
19731980
def test_insert_image(self):
19741981
try:
19751982
self.client.insert(fake_api.FAKE_IMAGE_NAME,

0 commit comments

Comments
 (0)