compose/tests/testcases.py

32 lines
754 B
Python
Raw Normal View History

from docker import Client
from plum.service import Service
import os
from unittest import TestCase
2013-12-10 21:47:08 +01:00
class DockerClientTestCase(TestCase):
@classmethod
def setUpClass(cls):
if os.environ.get('DOCKER_URL'):
cls.client = Client(os.environ['DOCKER_URL'])
else:
cls.client = Client()
cls.client.pull('ubuntu')
def setUp(self):
for c in self.client.containers(all=True):
self.client.kill(c['Id'])
self.client.remove_container(c['Id'])
2013-12-09 22:39:11 +01:00
def create_service(self, name, **kwargs):
return Service(
name=name,
client=self.client,
image="ubuntu",
command=["/bin/sleep", "300"],
2013-12-09 22:39:11 +01:00
**kwargs
)