forked from docker/docker-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_volume_test.py
68 lines (56 loc) · 2.23 KB
/
api_volume_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import docker
import pytest
from ..helpers import requires_api_version
from .base import BaseAPIIntegrationTest
class TestVolumes(BaseAPIIntegrationTest):
def test_create_volume(self):
name = 'perfectcherryblossom'
self.tmp_volumes.append(name)
result = self.client.create_volume(name)
assert 'Name' in result
assert result['Name'] == name
assert 'Driver' in result
assert result['Driver'] == 'local'
def test_create_volume_invalid_driver(self):
driver_name = 'invalid.driver'
with pytest.raises(docker.errors.NotFound):
self.client.create_volume('perfectcherryblossom', driver_name)
def test_list_volumes(self):
name = 'imperishablenight'
self.tmp_volumes.append(name)
volume_info = self.client.create_volume(name)
result = self.client.volumes()
assert 'Volumes' in result
volumes = result['Volumes']
assert volume_info in volumes
def test_inspect_volume(self):
name = 'embodimentofscarletdevil'
self.tmp_volumes.append(name)
volume_info = self.client.create_volume(name)
result = self.client.inspect_volume(name)
assert volume_info == result
def test_inspect_nonexistent_volume(self):
name = 'embodimentofscarletdevil'
with pytest.raises(docker.errors.NotFound):
self.client.inspect_volume(name)
def test_remove_volume(self):
name = 'shootthebullet'
self.tmp_volumes.append(name)
self.client.create_volume(name)
self.client.remove_volume(name)
@requires_api_version('1.25')
def test_force_remove_volume(self):
name = 'shootthebullet'
self.tmp_volumes.append(name)
self.client.create_volume(name)
self.client.remove_volume(name, force=True)
@requires_api_version('1.25')
def test_prune_volumes(self):
v = self.client.create_volume()
self.tmp_volumes.append(v["Name"])
result = self.client.prune_volumes()
assert v["Name"] in result['VolumesDeleted']
def test_remove_nonexistent_volume(self):
name = 'shootthebullet'
with pytest.raises(docker.errors.NotFound):
self.client.remove_volume(name)