Refactor migration logic
- Rename `migration` module to `legacy` to make its legacy-ness explicit - Move `check_for_legacy_containers` into `legacy` module - Fix migration test so it can be run in isolation Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
e538923545
commit
0fdb8bf814
6 changed files with 61 additions and 52 deletions
30
tests/integration/legacy_test.py
Normal file
30
tests/integration/legacy_test.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import mock
|
||||
|
||||
from compose import legacy
|
||||
from compose.project import Project
|
||||
from .testcases import DockerClientTestCase
|
||||
|
||||
|
||||
class ProjectTest(DockerClientTestCase):
|
||||
|
||||
def test_migration_to_labels(self):
|
||||
services = [
|
||||
self.create_service('web'),
|
||||
self.create_service('db'),
|
||||
]
|
||||
|
||||
project = Project('composetest', services, self.client)
|
||||
|
||||
for service in services:
|
||||
service.ensure_image_exists()
|
||||
self.client.create_container(
|
||||
name='{}_{}_1'.format(project.name, service.name),
|
||||
**service.options
|
||||
)
|
||||
|
||||
with mock.patch.object(legacy, 'log', autospec=True) as mock_log:
|
||||
self.assertEqual(project.containers(stopped=True), [])
|
||||
self.assertEqual(mock_log.warn.call_count, 2)
|
||||
|
||||
legacy.migrate_project_to_labels(project)
|
||||
self.assertEqual(len(project.containers(stopped=True)), 2)
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
import mock
|
||||
|
||||
from compose import service, migration
|
||||
from compose.project import Project
|
||||
from .testcases import DockerClientTestCase
|
||||
|
||||
|
||||
class ProjectTest(DockerClientTestCase):
|
||||
|
||||
def test_migration_to_labels(self):
|
||||
web = self.create_service('web')
|
||||
db = self.create_service('db')
|
||||
project = Project('composetest', [web, db], self.client)
|
||||
|
||||
self.client.create_container(name='composetest_web_1', **web.options)
|
||||
self.client.create_container(name='composetest_db_1', **db.options)
|
||||
|
||||
with mock.patch.object(service, 'log', autospec=True) as mock_log:
|
||||
self.assertEqual(project.containers(stopped=True), [])
|
||||
self.assertEqual(mock_log.warn.call_count, 2)
|
||||
|
||||
migration.migrate_project_to_labels(project)
|
||||
self.assertEqual(len(project.containers(stopped=True)), 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue