mirror of https://github.com/docker/compose.git
Move ServiceTestCase to separate module
This commit is contained in:
parent
dc4f90f3ed
commit
4cf072a013
|
@ -1,9 +1,9 @@
|
|||
from plum.service import Service
|
||||
from plum.service_collection import ServiceCollection
|
||||
from unittest import TestCase
|
||||
from .testcases import ServiceTestCase
|
||||
|
||||
|
||||
class ServiceCollectionTest(TestCase):
|
||||
class ServiceCollectionTest(ServiceTestCase):
|
||||
def test_from_dict(self):
|
||||
collection = ServiceCollection.from_dicts(None, [
|
||||
{
|
||||
|
@ -38,7 +38,3 @@ class ServiceCollectionTest(TestCase):
|
|||
|
||||
self.assertEqual(collection[0].name, 'db')
|
||||
self.assertEqual(collection[1].name, 'web')
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
from unittest import TestCase
|
||||
from docker import Client
|
||||
from plum import Service
|
||||
import os
|
||||
|
||||
|
||||
if os.environ.get('DOCKER_URL'):
|
||||
client = Client(os.environ['DOCKER_URL'])
|
||||
else:
|
||||
client = Client()
|
||||
client.pull('ubuntu')
|
||||
|
||||
|
||||
class ServiceTestCase(TestCase):
|
||||
def setUp(self):
|
||||
for c in client.containers(all=True):
|
||||
client.kill(c['Id'])
|
||||
client.remove_container(c['Id'])
|
||||
|
||||
def create_service(self, name):
|
||||
return Service(
|
||||
name=name,
|
||||
client=client,
|
||||
image="ubuntu",
|
||||
command=["/bin/sleep", "300"],
|
||||
)
|
||||
from .testcases import ServiceTestCase
|
||||
|
||||
|
||||
class NameTestCase(ServiceTestCase):
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
from docker import Client
|
||||
from plum.service import Service
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class ServiceTestCase(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'])
|
||||
|
||||
def create_service(self, name):
|
||||
return Service(
|
||||
name=name,
|
||||
client=self.client,
|
||||
image="ubuntu",
|
||||
command=["/bin/sleep", "300"],
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue