<s> import json <EOL> import pytest <EOL> from . . import base <EOL> from . api_test import DockerClientTest , url_prefix , fake_request <EOL> class VolumeTest ( DockerClientTest ) : <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_list_volumes ( self ) : <EOL> volumes = self . client . volumes ( ) <EOL> self . assertIn ( '<STR_LIT>' , volumes ) <EOL> self . assertEqual ( len ( volumes [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_list_volumes_and_filters ( self ) : <EOL> volumes = self . client . volumes ( filters = { '<STR_LIT>' : True } ) <EOL> assert '<STR_LIT>' in volumes <EOL> assert len ( volumes [ '<STR_LIT>' ] ) == <NUM_LIT:2> <EOL> args = fake_request . call_args <EOL> assert args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] == '<STR_LIT:GET>' <EOL> assert args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] == url_prefix + '<STR_LIT>' <EOL> assert args [ <NUM_LIT:1> ] == { '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT>' : <NUM_LIT> } <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_volume ( self ) : <EOL> name = '<STR_LIT>' <EOL> result = self . client . create_volume ( name ) <EOL> self . assertIn ( '<STR_LIT:Name>' , result ) <EOL> self . assertEqual ( result [ '<STR_LIT:Name>' ] , name ) <EOL> self . assertIn ( '<STR_LIT>' , result ) <EOL> self . assertEqual ( result [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT:POST>' ) <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , { '<STR_LIT:Name>' : name } ) <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_volume_with_driver ( self ) : <EOL> name = '<STR_LIT>' <EOL> driver_name = '<STR_LIT>' <EOL> self . client . create_volume ( name , driver = driver_name ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT:POST>' ) <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertIn ( '<STR_LIT>' , data ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] , driver_name ) <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_volume_invalid_opts_type ( self ) : <EOL> with pytest . raises ( TypeError ) : <EOL> self . client . create_volume ( <EOL> '<STR_LIT>' , driver_opts = '<STR_LIT>' <EOL> ) <EOL> with pytest . raises ( TypeError ) : <EOL> self . client . create_volume ( <EOL> '<STR_LIT>' , driver_opts = [ '<STR_LIT>' ] <EOL> ) <EOL> with pytest . raises ( TypeError ) : <EOL> self . client . create_volume ( <EOL> '<STR_LIT>' , driver_opts = '<STR_LIT>' <EOL> ) <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_inspect_volume ( self ) : <EOL> name = '<STR_LIT>' <EOL> result = self . client . inspect_volume ( name ) <EOL> self . assertIn ( '<STR_LIT:Name>' , result ) <EOL> self . assertEqual ( result [ '<STR_LIT:Name>' ] , name ) <EOL> self . assertIn ( '<STR_LIT>' , result ) <EOL> self . assertEqual ( result [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT:GET>' ) <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , '<STR_LIT>' . format ( url_prefix , name ) ) <EOL> @ base . requires_api_version ( '<STR_LIT>' ) <EOL> def test_remove_volume ( self ) : <EOL> name = '<STR_LIT>' <EOL> self . client . remove_volume ( name ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , '<STR_LIT>' . format ( url_prefix , name ) ) </s>
