def test_convert_service_to_bundle(): name = 'theservice' image_digest = 'thedigest' service_dict = { 'ports': ['80'], 'expose': ['1234'], 'networks': { 'extra': {} }, 'command': 'foo', 'entrypoint': 'entry', 'environment': { 'BAZ': 'ENV' }, 'build': '.', 'working_dir': '/tmp', 'user': '******', 'labels': { 'FOO': 'LABEL' }, 'privileged': True, } with mock.patch('compose.bundle.log.warn', autospec=True) as mock_log: config = bundle.convert_service_to_bundle(name, service_dict, image_digest) mock_log.assert_called_once_with( "Unsupported key 'privileged' in services.theservice - ignoring") assert config == { 'Image': image_digest, 'Ports': [ { 'Protocol': 'tcp', 'Port': 80 }, { 'Protocol': 'tcp', 'Port': 1234 }, ], 'Networks': ['extra'], 'Command': ['entry', 'foo'], 'Env': ['BAZ=ENV'], 'WorkingDir': '/tmp', 'User': '******', 'Labels': { 'FOO': 'LABEL' }, }
def test_convert_service_to_bundle(): name = 'theservice' image_digest = 'thedigest' service_dict = { 'ports': ['80'], 'expose': ['1234'], 'networks': {'extra': {}}, 'command': 'foo', 'entrypoint': 'entry', 'environment': {'BAZ': 'ENV'}, 'build': '.', 'working_dir': '/tmp', 'user': '******', 'labels': {'FOO': 'LABEL'}, 'privileged': True, } with mock.patch('compose.bundle.log.warn', autospec=True) as mock_log: config = bundle.convert_service_to_bundle(name, service_dict, image_digest) mock_log.assert_called_once_with( "Unsupported key 'privileged' in services.theservice - ignoring") assert config == { 'Image': image_digest, 'Ports': [ {'Protocol': 'tcp', 'Port': 80}, {'Protocol': 'tcp', 'Port': 1234}, ], 'Networks': ['extra'], 'Command': ['entry', 'foo'], 'Env': ['BAZ=ENV'], 'WorkingDir': '/tmp', 'User': '******', 'Labels': {'FOO': 'LABEL'}, }