Add start and stop to ServiceCollections

This commit is contained in:
Ben Firshman 2013-12-09 17:48:15 +00:00
parent 4cf072a013
commit 39497f6ee7
2 changed files with 27 additions and 0 deletions

View File

@ -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()

View File

@ -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)