mirror of https://github.com/docker/docker-py.git
Add random_name test helper
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
parent
6334312e47
commit
d98a879016
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import os.path
|
||||
import random
|
||||
import tarfile
|
||||
import tempfile
|
||||
import time
|
||||
|
@ -56,3 +57,7 @@ def wait_on_condition(condition, delay=0.1, timeout=40):
|
|||
if time.time() - start_time > timeout:
|
||||
raise AssertionError("Timeout: %s" % condition)
|
||||
time.sleep(delay)
|
||||
|
||||
|
||||
def random_name():
|
||||
return u'dockerpytest_{0:x}'.format(random.getrandbits(64))
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
import random
|
||||
|
||||
import docker
|
||||
from docker.utils import create_ipam_config
|
||||
from docker.utils import create_ipam_pool
|
||||
import pytest
|
||||
|
||||
from ..helpers import requires_api_version
|
||||
from ..helpers import random_name, requires_api_version
|
||||
from .base import BaseAPIIntegrationTest
|
||||
|
||||
|
||||
class TestNetworks(BaseAPIIntegrationTest):
|
||||
def create_network(self, *args, **kwargs):
|
||||
net_name = u'dockerpy{}'.format(random.getrandbits(24))[:14]
|
||||
net_name = random_name()
|
||||
net_id = self.client.create_network(net_name, *args, **kwargs)['Id']
|
||||
self.tmp_networks.append(net_id)
|
||||
return (net_name, net_id)
|
||||
|
@ -84,10 +82,8 @@ class TestNetworks(BaseAPIIntegrationTest):
|
|||
|
||||
@requires_api_version('1.21')
|
||||
def test_create_network_with_host_driver_fails(self):
|
||||
net_name = 'dockerpy{}'.format(random.getrandbits(24))[:14]
|
||||
|
||||
with pytest.raises(docker.errors.APIError):
|
||||
self.client.create_network(net_name, driver='host')
|
||||
self.client.create_network(random_name(), driver='host')
|
||||
|
||||
@requires_api_version('1.21')
|
||||
def test_remove_network(self):
|
||||
|
|
Loading…
Reference in New Issue