diff --git a/plum/tests/service_collection_test.py b/plum/tests/service_collection_test.py index 88641c0a9..1715c2999 100644 --- a/plum/tests/service_collection_test.py +++ b/plum/tests/service_collection_test.py @@ -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') - - - - diff --git a/plum/tests/service_test.py b/plum/tests/service_test.py index 992852337..49c4d5854 100644 --- a/plum/tests/service_test.py +++ b/plum/tests/service_test.py @@ -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): diff --git a/plum/tests/testcases.py b/plum/tests/testcases.py new file mode 100644 index 000000000..7be5b99be --- /dev/null +++ b/plum/tests/testcases.py @@ -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"], + ) + + +