summaryrefslogtreecommitdiff
path: root/tests/integration/models_volumes_test.py
blob: 094e68fadb417cf319ccfa76ca9c2f89c3092f89 (plain)
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
import docker
from .base import BaseIntegrationTest


class VolumesTest(BaseIntegrationTest):
    def test_create_get(self):
        client = docker.from_env()
        volume = client.volumes.create(
            'dockerpytest_1',
            driver='local',
            labels={'labelkey': 'labelvalue'}
        )
        self.tmp_volumes.append(volume.id)
        assert volume.id
        assert volume.name == 'dockerpytest_1'
        assert volume.attrs['Labels'] == {'labelkey': 'labelvalue'}

        volume = client.volumes.get(volume.id)
        assert volume.name == 'dockerpytest_1'

    def test_list_remove(self):
        client = docker.from_env()
        volume = client.volumes.create('dockerpytest_1')
        self.tmp_volumes.append(volume.id)
        assert volume in client.volumes.list()
        assert volume in client.volumes.list(filters={'name': 'dockerpytest_'})
        assert volume not in client.volumes.list(filters={'name': 'foobar'})

        volume.remove()
        assert volume not in client.volumes.list()