File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -526,6 +526,15 @@ Remove an image. Similar to the `docker rmi` command.
526
526
* force (bool ): Force removal of the image
527
527
* noprune (bool ): Do not delete untagged parents
528
528
529
+ # # rename
530
+
531
+ Rename a container. Similar to the `docker rename` command.
532
+
533
+ ** Params** :
534
+
535
+ * container (str ): ID of the container to rename
536
+ * name (str ): New name for the container
537
+
529
538
# # restart
530
539
531
540
Restart a container. Similar to the `docker restart` command.
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- CURRENT_VERSION = 'v1.16 '
15
+ CURRENT_VERSION = 'v1.17 '
16
16
17
17
FAKE_CONTAINER_ID = '3cc2351ab11b'
18
18
FAKE_IMAGE_ID = 'e9aa60c60128'
@@ -271,6 +271,11 @@ def post_fake_restart_container():
271
271
return status_code , response
272
272
273
273
274
+ def post_fake_rename_container ():
275
+ status_code = 204
276
+ return status_code , None
277
+
278
+
274
279
def delete_fake_remove_container ():
275
280
status_code = 200
276
281
response = {'Id' : FAKE_CONTAINER_ID }
@@ -348,6 +353,8 @@ def post_fake_tag_image():
348
353
post_fake_resize_container ,
349
354
'{1}/{0}/containers/3cc2351ab11b/json' .format (CURRENT_VERSION , prefix ):
350
355
get_fake_inspect_container ,
356
+ '{1}/{0}/containers/3cc2351ab11b/rename' .format (CURRENT_VERSION , prefix ):
357
+ post_fake_rename_container ,
351
358
'{1}/{0}/images/e9aa60c60128/tag' .format (CURRENT_VERSION , prefix ):
352
359
post_fake_tag_image ,
353
360
'{1}/{0}/containers/3cc2351ab11b/wait' .format (CURRENT_VERSION , prefix ):
Original file line number Diff line number Diff line change @@ -322,6 +322,18 @@ def runTest(self):
322
322
self .assertEqual ('/foobar' , inspect ['Name' ])
323
323
324
324
325
+ class TestRenameContainer (BaseTestCase ):
326
+ def runTest (self ):
327
+ name = 'hong_meiling'
328
+ res = self .client .create_container ('busybox' , 'true' )
329
+ self .assertIn ('Id' , res )
330
+ self .tmp_containers .append (res ['Id' ])
331
+ self .client .rename (res , name )
332
+ inspect = self .client .inspect_container (res ['Id' ])
333
+ self .assertIn ('Name' , inspect )
334
+ self .assertEqual (name , inspect ['Name' ])
335
+
336
+
325
337
class TestStartContainer (BaseTestCase ):
326
338
def runTest (self ):
327
339
res = self .client .create_container ('busybox' , 'true' )
Original file line number Diff line number Diff line change @@ -1256,6 +1256,21 @@ def test_resize_container(self):
1256
1256
timeout = docker .client .DEFAULT_TIMEOUT_SECONDS
1257
1257
)
1258
1258
1259
+ def test_rename_container (self ):
1260
+ try :
1261
+ self .client .rename (
1262
+ {'Id' : fake_api .FAKE_CONTAINER_ID },
1263
+ name = 'foobar'
1264
+ )
1265
+ except Exception as e :
1266
+ self .fail ('Command shold not raise exception: {0}' .format (e ))
1267
+
1268
+ fake_request .assert_called_with (
1269
+ url_prefix + 'containers/3cc2351ab11b/rename' ,
1270
+ params = {'name' : 'foobar' },
1271
+ timeout = docker .client .DEFAULT_TIMEOUT_SECONDS
1272
+ )
1273
+
1259
1274
def test_wait (self ):
1260
1275
try :
1261
1276
self .client .wait (fake_api .FAKE_CONTAINER_ID )
You can’t perform that action at this time.
0 commit comments