2013-12-09 18:36:44 +01:00
|
|
|
from docker import Client
|
2013-12-20 21:28:24 +01:00
|
|
|
from fig.service import Service
|
2013-12-31 13:37:17 +01:00
|
|
|
from fig.cli.utils import docker_url
|
2014-01-06 12:22:46 +01:00
|
|
|
from unittest2 import TestCase
|
2013-12-09 18:36:44 +01:00
|
|
|
|
|
|
|
|
2013-12-10 21:47:08 +01:00
|
|
|
class DockerClientTestCase(TestCase):
|
2013-12-09 18:36:44 +01:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2013-12-31 13:37:17 +01:00
|
|
|
cls.client = Client(docker_url())
|
2013-12-09 18:36:44 +01:00
|
|
|
cls.client.pull('ubuntu')
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
for c in self.client.containers(all=True):
|
2014-01-02 16:27:51 +01:00
|
|
|
if c['Names'] and 'figtest' in c['Names'][0]:
|
|
|
|
self.client.kill(c['Id'])
|
|
|
|
self.client.remove_container(c['Id'])
|
2013-12-09 18:36:44 +01:00
|
|
|
|
2013-12-09 22:39:11 +01:00
|
|
|
def create_service(self, name, **kwargs):
|
2013-12-09 18:36:44 +01:00
|
|
|
return Service(
|
2014-01-02 16:27:51 +01:00
|
|
|
project='figtest',
|
2013-12-09 18:36:44 +01:00
|
|
|
name=name,
|
|
|
|
client=self.client,
|
|
|
|
image="ubuntu",
|
|
|
|
command=["/bin/sleep", "300"],
|
2013-12-09 22:39:11 +01:00
|
|
|
**kwargs
|
2013-12-09 18:36:44 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|