<s> import datetime <EOL> import json <EOL> import signal <EOL> import docker <EOL> import pytest <EOL> import six <EOL> from . import fake_api <EOL> from . . base import requires_api_version <EOL> from . api_test import ( <EOL> DockerClientTest , url_prefix , fake_request , DEFAULT_TIMEOUT_SECONDS , <EOL> fake_inspect_container <EOL> ) <EOL> try : <EOL> from unittest import mock <EOL> except ImportError : <EOL> import mock <EOL> def fake_inspect_container_tty ( self , container ) : <EOL> return fake_inspect_container ( self , container , tty = True ) <EOL> class StartContainerTest ( DockerClientTest ) : <EOL> def test_start_container ( self ) : <EOL> self . client . start ( fake_api . FAKE_CONTAINER_ID ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , { } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_start_container_none ( self ) : <EOL> with pytest . raises ( ValueError ) as excinfo : <EOL> self . client . start ( container = None ) <EOL> self . assertEqual ( <EOL> str ( excinfo . value ) , <EOL> '<STR_LIT>' , <EOL> ) <EOL> with pytest . raises ( ValueError ) as excinfo : <EOL> self . client . start ( None ) <EOL> self . assertEqual ( <EOL> str ( excinfo . value ) , <EOL> '<STR_LIT>' , <EOL> ) <EOL> def test_start_container_regression_573 ( self ) : <EOL> self . client . start ( ** { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> def test_start_container_with_lxc_conf ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , <EOL> lxc_conf = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_lxc_conf_compat ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , <EOL> lxc_conf = [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ] <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_binds_ro ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , binds = { <EOL> '<STR_LIT>' : { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : True <EOL> } <EOL> } <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_binds_rw ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , binds = { <EOL> '<STR_LIT>' : { "<STR_LIT>" : '<STR_LIT>' , "<STR_LIT>" : False } <EOL> } <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_port_binds ( self ) : <EOL> self . maxDiff = None <EOL> def call_start ( ) : <EOL> self . client . start ( fake_api . FAKE_CONTAINER_ID , port_bindings = { <EOL> <NUM_LIT> : None , <EOL> <NUM_LIT> : <NUM_LIT> , <EOL> '<STR_LIT>' : ( <NUM_LIT> , ) , <EOL> <NUM_LIT> : ( '<STR_LIT:127.0.0.1>' , ) , <EOL> <NUM_LIT> : ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) , <EOL> <NUM_LIT> : [ ( '<STR_LIT:127.0.0.1>' , ) , ( '<STR_LIT>' , ) ] <EOL> } ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_links ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , links = { '<STR_LIT:path>' : '<STR_LIT>' } <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_multiple_links ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( <EOL> fake_api . FAKE_CONTAINER_ID , <EOL> links = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_links_as_list_of_tuples ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( fake_api . FAKE_CONTAINER_ID , <EOL> links = [ ( '<STR_LIT:path>' , '<STR_LIT>' ) ] ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_privileged ( self ) : <EOL> def call_start ( ) : <EOL> self . client . start ( fake_api . FAKE_CONTAINER_ID , privileged = True ) <EOL> pytest . deprecated_call ( call_start ) <EOL> def test_start_container_with_dict_instead_of_id ( self ) : <EOL> self . client . start ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , { } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> class CreateContainerTest ( DockerClientTest ) : <EOL> def test_create_container ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:true>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_binds ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> self . client . create_container ( '<STR_LIT>' , [ '<STR_LIT>' , mount_dest ] , <EOL> volumes = [ mount_dest ] ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_volume_string ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> self . client . create_container ( '<STR_LIT>' , [ '<STR_LIT>' , mount_dest ] , <EOL> volumes = mount_dest ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_ports ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT>' , <EOL> ports = [ <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT>' ) , ( <NUM_LIT> , ) ] ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_entrypoint ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:hello>' , <EOL> entrypoint = '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_cpu_shares ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT>' , <EOL> cpu_shares = <NUM_LIT:5> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_cpuset ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT>' , <EOL> cpuset = '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_cgroup_parent ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT>' , host_config = self . client . create_host_config ( <EOL> cgroup_parent = '<STR_LIT:test>' <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertIn ( '<STR_LIT>' , data ) <EOL> self . assertIn ( '<STR_LIT>' , data [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , '<STR_LIT:test>' ) <EOL> def test_create_container_with_working_dir ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT>' , <EOL> working_dir = '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_stdin_open ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:true>' , stdin_open = True ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_with_volumes_from ( self ) : <EOL> vol_names = [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> try : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:true>' , <EOL> volumes_from = vol_names ) <EOL> except docker . errors . DockerException : <EOL> self . assertTrue ( <EOL> docker . utils . compare_version ( '<STR_LIT>' , self . client . _version ) >= <NUM_LIT:0> <EOL> ) <EOL> return <EOL> args = fake_request . call_args <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>' ] , <EOL> '<STR_LIT:U+002C>' . join ( vol_names ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> def test_create_container_empty_volumes_from ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:true>' , volumes_from = [ ] ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertTrue ( '<STR_LIT>' not in data ) <EOL> def test_create_named_container ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT:true>' , <EOL> name = '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> def test_create_container_with_mem_limit_as_int ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> mem_limit = <NUM_LIT> <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_create_container_with_mem_limit_as_string ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> mem_limit = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_create_container_with_mem_limit_as_string_with_k_unit ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> mem_limit = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <NUM_LIT> * <NUM_LIT> ) <EOL> def test_create_container_with_mem_limit_as_string_with_m_unit ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> mem_limit = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertEqual ( data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <NUM_LIT> * <NUM_LIT> * <NUM_LIT> ) <EOL> def test_create_container_with_mem_limit_as_string_with_g_unit ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> mem_limit = '<STR_LIT>' <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> data = json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) <EOL> self . assertEqual ( <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <NUM_LIT> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT> <EOL> ) <EOL> def test_create_container_with_mem_limit_as_string_with_wrong_value ( self ) : <EOL> self . assertRaises ( <EOL> docker . errors . DockerException , <EOL> self . client . create_host_config , mem_limit = '<STR_LIT>' <EOL> ) <EOL> self . assertRaises ( <EOL> docker . errors . DockerException , <EOL> self . client . create_host_config , mem_limit = '<STR_LIT>' <EOL> ) <EOL> def test_create_container_with_lxc_conf ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> lxc_conf = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' <EOL> ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_lxc_conf_compat ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> lxc_conf = [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ] <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> ] <EOL> self . assertEqual ( <EOL> json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_binds_ro ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> mount_origin = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> binds = { mount_origin : { <EOL> "<STR_LIT>" : mount_dest , <EOL> "<STR_LIT>" : True <EOL> } } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ "<STR_LIT>" ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_binds_rw ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> mount_origin = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> binds = { mount_origin : { <EOL> "<STR_LIT>" : mount_dest , <EOL> "<STR_LIT>" : False <EOL> } } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ "<STR_LIT>" ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_binds_mode ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> mount_origin = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> binds = { mount_origin : { <EOL> "<STR_LIT>" : mount_dest , <EOL> "<STR_LIT>" : "<STR_LIT:z>" , <EOL> } } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ "<STR_LIT>" ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_binds_mode_and_ro_error ( self ) : <EOL> with pytest . raises ( ValueError ) : <EOL> mount_dest = '<STR_LIT>' <EOL> mount_origin = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> binds = { mount_origin : { <EOL> "<STR_LIT>" : mount_dest , <EOL> "<STR_LIT>" : "<STR_LIT:z>" , <EOL> "<STR_LIT>" : True , <EOL> } } <EOL> ) <EOL> ) <EOL> def test_create_container_with_binds_list ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> binds = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] , <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_port_binds ( self ) : <EOL> self . maxDiff = None <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> port_bindings = { <EOL> <NUM_LIT> : None , <EOL> <NUM_LIT> : <NUM_LIT> , <EOL> '<STR_LIT>' : ( <NUM_LIT> , ) , <EOL> <NUM_LIT> : ( '<STR_LIT:127.0.0.1>' , ) , <EOL> <NUM_LIT> : ( '<STR_LIT:127.0.0.1>' , <NUM_LIT> ) , <EOL> <NUM_LIT> : [ ( '<STR_LIT:127.0.0.1>' , ) , ( '<STR_LIT>' , ) ] <EOL> } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <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> port_bindings = data [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertTrue ( '<STR_LIT>' in port_bindings ) <EOL> self . assertEqual ( <EOL> [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> port_bindings [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertEqual ( <EOL> [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> port_bindings [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertEqual ( <EOL> [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> port_bindings [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertEqual ( <EOL> [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:127.0.0.1>" } ] , <EOL> port_bindings [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertEqual ( <EOL> [ { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:127.0.0.1>" } ] , <EOL> port_bindings [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertEqual ( len ( port_bindings [ '<STR_LIT>' ] ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_mac_address ( self ) : <EOL> mac_address_expected = "<STR_LIT>" <EOL> container = self . client . create_container ( <EOL> '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , mac_address = mac_address_expected ) <EOL> res = self . client . inspect_container ( container [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( mac_address_expected , <EOL> res [ '<STR_LIT>' ] [ '<STR_LIT>' ] ) <EOL> def test_create_container_with_links ( self ) : <EOL> link_path = '<STR_LIT:path>' <EOL> alias = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> links = { link_path : alias } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' <EOL> ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> def test_create_container_with_multiple_links ( self ) : <EOL> link_path = '<STR_LIT:path>' <EOL> alias = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> links = { <EOL> link_path + '<STR_LIT:1>' : alias + '<STR_LIT:1>' , <EOL> link_path + '<STR_LIT:2>' : alias + '<STR_LIT:2>' <EOL> } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> def test_create_container_with_links_as_list_of_tuples ( self ) : <EOL> link_path = '<STR_LIT:path>' <EOL> alias = '<STR_LIT>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> links = [ ( link_path , alias ) ] <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> def test_create_container_privileged ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> host_config = self . client . create_host_config ( privileged = True ) <EOL> ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = True <EOL> args = fake_request . call_args <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>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_restart_policy ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> restart_policy = { <EOL> "<STR_LIT:Name>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:0> <EOL> } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT:Name>" : "<STR_LIT>" <EOL> } <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_added_capabilities ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> host_config = self . client . create_host_config ( cap_add = [ '<STR_LIT>' ] ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_dropped_capabilities ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> host_config = self . client . create_host_config ( cap_drop = [ '<STR_LIT>' ] ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_devices ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> devices = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_labels_dict ( self ) : <EOL> labels_dict = { <EOL> six . text_type ( '<STR_LIT:foo>' ) : six . text_type ( '<STR_LIT:1>' ) , <EOL> six . text_type ( '<STR_LIT:bar>' ) : six . text_type ( '<STR_LIT:2>' ) , <EOL> } <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> labels = labels_dict , <EOL> ) <EOL> args = fake_request . call_args <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>' ] , labels_dict ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_labels_list ( self ) : <EOL> labels_list = [ <EOL> six . text_type ( '<STR_LIT:foo>' ) , <EOL> six . text_type ( '<STR_LIT:bar>' ) , <EOL> ] <EOL> labels_dict = { <EOL> six . text_type ( '<STR_LIT:foo>' ) : six . text_type ( ) , <EOL> six . text_type ( '<STR_LIT:bar>' ) : six . text_type ( ) , <EOL> } <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> labels = labels_list , <EOL> ) <EOL> args = fake_request . call_args <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>' ] , labels_dict ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_named_volume ( self ) : <EOL> mount_dest = '<STR_LIT>' <EOL> volume_name = '<STR_LIT:name>' <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , <EOL> host_config = self . client . create_host_config ( <EOL> binds = { volume_name : { <EOL> "<STR_LIT>" : mount_dest , <EOL> "<STR_LIT>" : False <EOL> } } ) , <EOL> volume_driver = '<STR_LIT>' , <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' <EOL> ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = [ "<STR_LIT>" ] <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_create_container_with_stop_signal ( self ) : <EOL> self . client . create_container ( '<STR_LIT>' , '<STR_LIT>' , <EOL> stop_signal = '<STR_LIT>' ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <EOL> url_prefix + '<STR_LIT>' ) <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> @ requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_container_with_aliases ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> host_config = self . client . create_host_config ( <EOL> network_mode = '<STR_LIT>' , <EOL> ) , <EOL> networking_config = self . client . create_networking_config ( { <EOL> '<STR_LIT>' : self . client . create_endpoint_config ( <EOL> aliases = [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] , <EOL> ) , <EOL> } ) , <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> json . loads ( '''<STR_LIT>''' ) ) <EOL> @ requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_container_with_tmpfs_list ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> tmpfs = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> @ requires_api_version ( '<STR_LIT>' ) <EOL> def test_create_container_with_tmpfs_dict ( self ) : <EOL> self . client . create_container ( <EOL> '<STR_LIT>' , '<STR_LIT:true>' , host_config = self . client . create_host_config ( <EOL> tmpfs = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> ) <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + <EOL> '<STR_LIT>' ) <EOL> expected_payload = self . base_create_payload ( ) <EOL> expected_payload [ '<STR_LIT>' ] = self . client . create_host_config ( ) <EOL> expected_payload [ '<STR_LIT>' ] [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> self . assertEqual ( json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , expected_payload ) <EOL> self . assertEqual ( args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> { '<STR_LIT:Content-Type>' : '<STR_LIT:application/json>' } ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , <EOL> DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> class ContainerTest ( DockerClientTest ) : <EOL> def test_list_containers ( self ) : <EOL> self . client . containers ( all = True ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { <EOL> '<STR_LIT:all>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT:size>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : - <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : None <EOL> } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_resize_container ( self ) : <EOL> self . client . resize ( <EOL> { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } , <EOL> height = <NUM_LIT:15> , <EOL> width = <NUM_LIT> <EOL> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:h>' : <NUM_LIT:15> , '<STR_LIT:w>' : <NUM_LIT> } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_rename_container ( self ) : <EOL> self . client . rename ( <EOL> { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } , <EOL> name = '<STR_LIT>' <EOL> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:name>' : '<STR_LIT>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_wait ( self ) : <EOL> self . client . wait ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = None <EOL> ) <EOL> def test_wait_with_dict_instead_of_id ( self ) : <EOL> self . client . wait ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = None <EOL> ) <EOL> def test_logs ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> logs = self . client . logs ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> self . assertEqual ( <EOL> logs , <EOL> '<STR_LIT>' . encode ( '<STR_LIT:ascii>' ) <EOL> ) <EOL> def test_logs_with_dict_instead_of_id ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> logs = self . client . logs ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> self . assertEqual ( <EOL> logs , <EOL> '<STR_LIT>' . encode ( '<STR_LIT:ascii>' ) <EOL> ) <EOL> def test_log_streaming ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = True , <EOL> follow = False ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = True <EOL> ) <EOL> def test_log_following ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = False , <EOL> follow = True ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> def test_log_following_backwards ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = True ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = True <EOL> ) <EOL> def test_log_streaming_and_following ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = True , <EOL> follow = True ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = True <EOL> ) <EOL> def test_log_tail ( self ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = False , <EOL> follow = False , tail = <NUM_LIT:10> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:10> } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> def test_log_since ( self ) : <EOL> ts = <NUM_LIT> <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = False , <EOL> follow = False , since = ts ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' , '<STR_LIT>' : ts } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> def test_log_since_with_datetime ( self ) : <EOL> ts = <NUM_LIT> <EOL> time = datetime . datetime . utcfromtimestamp ( ts ) <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , stream = False , <EOL> follow = False , since = time ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' , '<STR_LIT>' : ts } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = False <EOL> ) <EOL> def test_log_tty ( self ) : <EOL> m = mock . Mock ( ) <EOL> with mock . patch ( '<STR_LIT>' , <EOL> fake_inspect_container_tty ) : <EOL> with mock . patch ( '<STR_LIT>' , <EOL> m ) : <EOL> self . client . logs ( fake_api . FAKE_CONTAINER_ID , <EOL> follow = True , stream = True ) <EOL> self . assertTrue ( m . called ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : <NUM_LIT:0> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT:all>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS , <EOL> stream = True <EOL> ) <EOL> def test_diff ( self ) : <EOL> self . client . diff ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_diff_with_dict_instead_of_id ( self ) : <EOL> self . client . diff ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_port ( self ) : <EOL> self . client . port ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } , <NUM_LIT> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_stop_container ( self ) : <EOL> timeout = <NUM_LIT:2> <EOL> self . client . stop ( fake_api . FAKE_CONTAINER_ID , timeout = timeout ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:t>' : timeout } , <EOL> timeout = ( DEFAULT_TIMEOUT_SECONDS + timeout ) <EOL> ) <EOL> def test_stop_container_with_dict_instead_of_id ( self ) : <EOL> timeout = <NUM_LIT:2> <EOL> self . client . stop ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } , <EOL> timeout = timeout ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:t>' : timeout } , <EOL> timeout = ( DEFAULT_TIMEOUT_SECONDS + timeout ) <EOL> ) <EOL> def test_pause_container ( self ) : <EOL> self . client . pause ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = ( DEFAULT_TIMEOUT_SECONDS ) <EOL> ) <EOL> def test_unpause_container ( self ) : <EOL> self . client . unpause ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = ( DEFAULT_TIMEOUT_SECONDS ) <EOL> ) <EOL> def test_kill_container ( self ) : <EOL> self . client . kill ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_kill_container_with_dict_instead_of_id ( self ) : <EOL> self . client . kill ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_kill_container_with_signal ( self ) : <EOL> self . client . kill ( fake_api . FAKE_CONTAINER_ID , signal = signal . SIGTERM ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : signal . SIGTERM } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_restart_container ( self ) : <EOL> self . client . restart ( fake_api . FAKE_CONTAINER_ID , timeout = <NUM_LIT:2> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:t>' : <NUM_LIT:2> } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_restart_container_with_dict_instead_of_id ( self ) : <EOL> self . client . restart ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } , timeout = <NUM_LIT:2> ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:POST>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:t>' : <NUM_LIT:2> } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_remove_container ( self ) : <EOL> self . client . remove_container ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:v>' : False , '<STR_LIT>' : False , '<STR_LIT>' : False } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_remove_container_with_dict_instead_of_id ( self ) : <EOL> self . client . remove_container ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT:v>' : False , '<STR_LIT>' : False , '<STR_LIT>' : False } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_export ( self ) : <EOL> self . client . export ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> stream = True , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_export_with_dict_instead_of_id ( self ) : <EOL> self . client . export ( { '<STR_LIT>' : fake_api . FAKE_CONTAINER_ID } ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> stream = True , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_inspect_container ( self ) : <EOL> self . client . inspect_container ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_inspect_container_undefined_id ( self ) : <EOL> for arg in None , '<STR_LIT>' , { True : True } : <EOL> with pytest . raises ( docker . errors . NullResource ) as excinfo : <EOL> self . client . inspect_container ( arg ) <EOL> self . assertEqual ( <EOL> excinfo . value . args [ <NUM_LIT:0> ] , '<STR_LIT>' <EOL> ) <EOL> def test_container_stats ( self ) : <EOL> self . client . stats ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> timeout = <NUM_LIT> , <EOL> stream = True <EOL> ) <EOL> def test_container_top ( self ) : <EOL> self . client . top ( fake_api . FAKE_CONTAINER_ID ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> def test_container_top_with_psargs ( self ) : <EOL> self . client . top ( fake_api . FAKE_CONTAINER_ID , '<STR_LIT>' ) <EOL> fake_request . assert_called_with ( <EOL> '<STR_LIT:GET>' , <EOL> url_prefix + '<STR_LIT>' , <EOL> params = { '<STR_LIT>' : '<STR_LIT>' } , <EOL> timeout = DEFAULT_TIMEOUT_SECONDS <EOL> ) <EOL> @ requires_api_version ( '<STR_LIT>' ) <EOL> def test_container_update ( self ) : <EOL> self . client . update_container ( <EOL> fake_api . FAKE_CONTAINER_ID , mem_limit = '<STR_LIT>' , cpu_shares = <NUM_LIT> , <EOL> blkio_weight = <NUM_LIT> <EOL> ) <EOL> args = fake_request . call_args <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , url_prefix + '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> json . loads ( args [ <NUM_LIT:1> ] [ '<STR_LIT:data>' ] ) , <EOL> { '<STR_LIT>' : <NUM_LIT:2> * <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } <EOL> ) <EOL> self . assertEqual ( <EOL> args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT:Content-Type>' ] , '<STR_LIT:application/json>' <EOL> ) </s>
