Exemple #1
0
    def test_sort_service_dicts_self_imports(self):
        services = [
            {
                'links': ['web'],
                'name': 'web'
            },
        ]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('web', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #2
0
    def test_sort_service_dicts_self_imports(self):
        services = [
            {
                'links': ['web'],
                'name': 'web'
            },
        ]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('web', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #3
0
    def test_sort_service_dicts_7(self):
        services = [
            {
                'net': 'container:three',
                'name': 'four'
            },
            {
                'links': ['two'],
                'name': 'three'
            },
            {
                'name': 'two',
                'volumes_from': ['one']
            },
            {
                'name': 'one'
            }
        ]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 4)
        self.assertEqual(sorted_services[0]['name'], 'one')
        self.assertEqual(sorted_services[1]['name'], 'two')
        self.assertEqual(sorted_services[2]['name'], 'three')
        self.assertEqual(sorted_services[3]['name'], 'four')
Exemple #4
0
    def test_sort_service_dicts_circular_imports_2(self):
        services = [{
            'links': ['postgres', 'redis'],
            'name': 'web'
        }, {
            'name': 'redis',
            'links': ['web']
        }, {
            'name': 'postgres'
        }]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('redis', e.msg)
            self.assertIn('web', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #5
0
    def test_sort_service_dicts_circular_imports_3(self):
        services = [{
            'links': ['b'],
            'name': 'a'
        }, {
            'name': 'b',
            'links': ['c']
        }, {
            'name': 'c',
            'links': ['a']
        }]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('a', e.msg)
            self.assertIn('b', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #6
0
    def test_sort_service_dicts_circular_imports_2(self):
        services = [
            {
                'links': ['postgres', 'redis'],
                'name': 'web'
            },
            {
                'name': 'redis',
                'links': ['web']
            },
            {
                'name': 'postgres'
            }
        ]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('redis', e.msg)
            self.assertIn('web', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #7
0
    def test_sort_service_dicts_circular_imports_3(self):
        services = [
            {
                'links': ['b'],
                'name': 'a'
            },
            {
                'name': 'b',
                'links': ['c']
            },
            {
                'name': 'c',
                'links': ['a']
            }
        ]

        try:
            sort_service_dicts(services)
        except DependencyError as e:
            self.assertIn('a', e.msg)
            self.assertIn('b', e.msg)
        else:
            self.fail('Should have thrown an DependencyError')
Exemple #8
0
    def test_sort_service_dicts_1(self):
        services = [{
            'links': ['redis'],
            'name': 'web'
        }, {
            'name': 'grunt'
        }, {
            'name': 'redis'
        }]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'grunt')
        self.assertEqual(sorted_services[1]['name'], 'redis')
        self.assertEqual(sorted_services[2]['name'], 'web')
Exemple #9
0
    def test_sort_service_dicts_6(self):
        services = [{
            'links': ['parent'],
            'name': 'grandparent'
        }, {
            'name': 'parent',
            'volumes_from': ['child']
        }, {
            'name': 'child'
        }]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'child')
        self.assertEqual(sorted_services[1]['name'], 'parent')
        self.assertEqual(sorted_services[2]['name'], 'grandparent')
Exemple #10
0
    def test_sort_service_dicts_5(self):
        services = [{
            'links': ['parent'],
            'name': 'grandparent'
        }, {
            'name': 'parent',
            'net': 'container:child'
        }, {
            'name': 'child'
        }]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'child')
        self.assertEqual(sorted_services[1]['name'], 'parent')
        self.assertEqual(sorted_services[2]['name'], 'grandparent')
Exemple #11
0
    def test_sort_service_dicts_1(self):
        services = [
            {
                'links': ['redis'],
                'name': 'web'
            },
            {
                'name': 'grunt'
            },
            {
                'name': 'redis'
            }
        ]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'grunt')
        self.assertEqual(sorted_services[1]['name'], 'redis')
        self.assertEqual(sorted_services[2]['name'], 'web')
Exemple #12
0
    def test_sort_service_dicts_7(self):
        services = [{
            'net': 'container:three',
            'name': 'four'
        }, {
            'links': ['two'],
            'name': 'three'
        }, {
            'name': 'two',
            'volumes_from': ['one']
        }, {
            'name': 'one'
        }]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 4)
        self.assertEqual(sorted_services[0]['name'], 'one')
        self.assertEqual(sorted_services[1]['name'], 'two')
        self.assertEqual(sorted_services[2]['name'], 'three')
        self.assertEqual(sorted_services[3]['name'], 'four')
Exemple #13
0
    def test_sort_service_dicts_5(self):
        services = [
            {
                'links': ['parent'],
                'name': 'grandparent'
            },
            {
                'name': 'parent',
                'net': 'container:child'
            },
            {
                'name': 'child'
            }
        ]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'child')
        self.assertEqual(sorted_services[1]['name'], 'parent')
        self.assertEqual(sorted_services[2]['name'], 'grandparent')
Exemple #14
0
    def test_sort_service_dicts_4(self):
        services = [
            {
                'name': 'child'
            },
            {
                'name': 'parent',
                'volumes_from': ['child']
            },
            {
                'links': ['parent'],
                'name': 'grandparent'
            },
        ]

        sorted_services = sort_service_dicts(services)
        self.assertEqual(len(sorted_services), 3)
        self.assertEqual(sorted_services[0]['name'], 'child')
        self.assertEqual(sorted_services[1]['name'], 'parent')
        self.assertEqual(sorted_services[2]['name'], 'grandparent')