mirror of https://github.com/docker/compose.git
Add start and stop to ServiceCollections
This commit is contained in:
parent
4cf072a013
commit
39497f6ee7
|
@ -34,4 +34,13 @@ class ServiceCollection(list):
|
|||
if service.name == name:
|
||||
return service
|
||||
|
||||
def start(self):
|
||||
for container in self:
|
||||
container.start()
|
||||
|
||||
def stop(self):
|
||||
for container in self:
|
||||
container.stop()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -38,3 +38,21 @@ class ServiceCollectionTest(ServiceTestCase):
|
|||
|
||||
self.assertEqual(collection[0].name, 'db')
|
||||
self.assertEqual(collection[1].name, 'web')
|
||||
|
||||
def test_start_stop(self):
|
||||
collection = ServiceCollection([
|
||||
self.create_service('web'),
|
||||
self.create_service('db'),
|
||||
])
|
||||
|
||||
collection.start()
|
||||
|
||||
self.assertEqual(len(collection[0].containers), 1)
|
||||
self.assertEqual(len(collection[1].containers), 1)
|
||||
|
||||
collection.stop()
|
||||
|
||||
self.assertEqual(len(collection[0].containers), 0)
|
||||
self.assertEqual(len(collection[1].containers), 0)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue