Test URL construction

This commit is contained in:
Joffrey F 2015-08-31 15:01:40 -07:00
parent 0f3d7673f3
commit 3d884f9a3c
1 changed files with 22 additions and 0 deletions

View File

@ -144,6 +144,28 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
'Version parameter must be a string or None. Found float'
)
def test_url_valid_resource(self):
url = self.client._url('/hello/{0}/world', 'somename')
self.assertEqual(
url, '{0}{1}'.format(url_prefix, 'hello/somename/world')
)
url = self.client._url('/hello/{0}/world', '/some?name')
self.assertEqual(
url, '{0}{1}'.format(url_prefix, 'hello/%2Fsome%3Fname/world')
)
def test_url_invalid_resource(self):
with pytest.raises(ValueError):
self.client._url('/hello/{0}/world', ['sakuya', 'izayoi'])
def test_url_no_resource(self):
url = self.client._url('/simple')
self.assertEqual(url, '{0}{1}'.format(url_prefix, 'simple'))
url = self.client._url('/simple', None)
self.assertEqual(url, '{0}{1}'.format(url_prefix, 'simple'))
#########################
# INFORMATION TESTS #
#########################