コード例 #1
0
ファイル: app_test.py プロジェクト: gitter-badger/riptide-lib
    def test_get_services_by_role(self):

        SEARCHED_ROLE = 'needle'

        service_no_roles = {'$name': 'service1'}

        service_searched_role1 = {
            '$name': 'service1',
            'roles': ['role1', SEARCHED_ROLE, 'role2', 'role3']
        }

        service_searched_role2 = {
            '$name': 'service2',
            'roles': ['role1', SEARCHED_ROLE, 'role2', 'role3']
        }

        doc = {
            'name': 'test',
            'services': {
                'service_no_roles': service_no_roles,
                'service_searched_role1': service_searched_role1,
                'service_searched_role2': service_searched_role2
            }
        }

        app = module.App(doc)

        self.assertEqual([service_searched_role1, service_searched_role2],
                         app.get_services_by_role(SEARCHED_ROLE))
コード例 #2
0
ファイル: app_test.py プロジェクト: gitter-badger/riptide-lib
    def test_resolve_and_merge_references_with_commands(self):
        paths = ['path1', 'path2']

        cmd1 = {'key1': 'value1'}
        cmd2 = {'key2': 'value2'}
        doc = {'name': 'test', 'commands': {'cmd1': cmd1, 'cmd2': cmd2}}

        with mock.patch("riptide.config.document.app.load_subdocument",
                        side_effect=side_effect_for_load_subdocument()
                        ) as load_subdoc_mock:
            app = module.App(doc)
            app.resolve_and_merge_references(paths)

            self.assertIsInstance(app['commands']['cmd1'],
                                  YamlConfigDocumentStub)
            self.assertIsInstance(app['commands']['cmd2'],
                                  YamlConfigDocumentStub)
            self.assertEqual({
                '$name': 'cmd1',
                'key1': 'value1'
            }, app['commands']['cmd1'].doc)
            self.assertEqual({
                '$name': 'cmd2',
                'key2': 'value2'
            }, app['commands']['cmd2'].doc)

            load_subdoc_mock.assert_has_calls([
                call(cmd1, app, module.Command, paths),
                call(cmd2, app, module.Command, paths)
            ],
                                              any_order=True)
コード例 #3
0
ファイル: app_test.py プロジェクト: gitter-badger/riptide-lib
    def test_resolve_and_merge_references_with_services_no_dict(self):

        paths = ['path1', 'path2']

        service1 = 'nodict'
        doc = {
            'name': 'test',
            'services': {
                'service1': service1,
            }
        }

        with mock.patch("riptide.config.document.app.load_subdocument",
                        side_effect=side_effect_for_load_subdocument()):
            app = module.App(doc)
            with self.assertRaises(ConfigcrunchError):
                app.resolve_and_merge_references(paths)
コード例 #4
0
ファイル: app_test.py プロジェクト: gitter-badger/riptide-lib
 def test_resolve_and_merge_references_no_subdocs(self, super_mock):
     doc = {'name': 'test'}
     app = module.App(doc)
     app.resolve_and_merge_references(['./path1', './path2'])
     super_mock.assert_called_once_with(['./path1', './path2'])
コード例 #5
0
ファイル: app_test.py プロジェクト: gitter-badger/riptide-lib
 def test_header(self):
     app = module.App({})
     self.assertEqual(module.HEADER, app.header())