image/appc: fix volume conversion and add tests

This commit is contained in:
Jimmy Zelinskie 2017-01-31 15:37:16 -05:00
parent 048f932094
commit 7a957c94c8
3 changed files with 24 additions and 3 deletions

View file

@ -2,6 +2,7 @@ import pytest
from image.appc import DockerV1ToACIManifestTranslator
from data.interfaces.verbs import RepositoryReference, ImageWithBlob
from util.dict_wrappers import JSONPathDict
EXAMPLE_MANIFEST_OBJ = {
@ -96,3 +97,16 @@ def test_legacy_port_conversion(repo_image):
ports.sort()
assert {'name':'port-8080', 'port':8080, 'protocol':'tcp'} == ports[0]
assert {'name':'port-8081', 'port':8081, 'protocol':'tcp'} == ports[1]
@pytest.mark.parametrize("vcfg,expected", [
({'Volumes': None}, []),
({'Volumes': {}}, []),
({'Volumes': {'/bin': {}}}, [{'name': 'volume-bin', 'path': '/bin', 'readOnly': False}]),
({'volumes': None}, []),
({'volumes': {}}, []),
({'volumes': {'/bin': {}}}, [{'name': 'volume-bin', 'path': '/bin', 'readOnly': False}]),
])
def test_volume_version_easy(vcfg, expected):
output = DockerV1ToACIManifestTranslator._build_volumes(JSONPathDict(vcfg))
assert output == expected