Pārlūkot izejas kodu

Fix --timeout flag on restart, add tests for stop and restart

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 10 gadi atpakaļ
vecāks
revīzija
2291fa2d45
2 mainītis faili ar 14 papildinājumiem un 3 dzēšanām
  1. 2 2
      compose/container.py
  2. 12 1
      tests/integration/cli_test.py

+ 2 - 2
compose/container.py

@@ -126,8 +126,8 @@ class Container(object):
     def kill(self, **options):
         return self.client.kill(self.id, **options)
 
-    def restart(self):
-        return self.client.restart(self.id)
+    def restart(self, **options):
+        return self.client.restart(self.id, **options)
 
     def remove(self, **options):
         return self.client.remove_container(self.id, **options)

+ 12 - 1
tests/integration/cli_test.py

@@ -332,6 +332,17 @@ class CLITestCase(DockerClientTestCase):
         self.command.dispatch(['rm', '-f'], None)
         self.assertEqual(len(service.containers(stopped=True)), 0)
 
+    def test_stop(self):
+        self.command.dispatch(['up', '-d'], None)
+        service = self.project.get_service('simple')
+        self.assertEqual(len(service.containers()), 1)
+        self.assertTrue(service.containers()[0].is_running)
+
+        self.command.dispatch(['stop', '-t', '1'], None)
+
+        self.assertEqual(len(service.containers(stopped=True)), 1)
+        self.assertFalse(service.containers(stopped=True)[0].is_running)
+
     def test_kill(self):
         self.command.dispatch(['up', '-d'], None)
         service = self.project.get_service('simple')
@@ -371,7 +382,7 @@ class CLITestCase(DockerClientTestCase):
         container = service.create_container()
         service.start_container(container)
         started_at = container.dictionary['State']['StartedAt']
-        self.command.dispatch(['restart'], None)
+        self.command.dispatch(['restart', '-t', '1'], None)
         container.inspect()
         self.assertNotEqual(
             container.dictionary['State']['FinishedAt'],