This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/model/helpers/test/test_build_helper.py
Charlton Austin f701677a8e refactor(data): add in new config for builder
we are doing phase one of the four phase migration on the builder config
2017-03-20 13:03:41 -04:00

30 lines
1.5 KiB
Python

import pytest
from data.model.helpers.build_helper import _get_config_expand
@pytest.mark.parametrize('org_config,expected', [
# Empty config
(None, {}),
# No subdir in config
({}, {}),
({"subdir": ""}, {"context": "/", "dockerfile_path": "/Dockerfile", "subdir": ""}),
({"subdir": "/"}, {"context": "/", "dockerfile_path": "/Dockerfile", "subdir": "/"}),
({"subdir": "/Dockerfile"}, {"context": "/", "dockerfile_path": "/Dockerfile", "subdir": "/Dockerfile"}),
({"subdir": "a"}, {"context": "a", "dockerfile_path": "a/Dockerfile", "subdir": "a"}),
({"subdir": "Dockerfile"}, {"context": "/", "dockerfile_path": "Dockerfile", "subdir": "Dockerfile"}),
({"subdir": "server.Dockerfile"},
{"context": "/", "dockerfile_path": "server.Dockerfile", "subdir": "server.Dockerfile"}),
({"subdir": "/a/b/Dockerfile"},
{"context": "/a/b", "dockerfile_path": "/a/b/Dockerfile", "subdir": "/a/b/Dockerfile"}),
({"subdir": "/a/b/server.Dockerfile"},
{"context": "/a/b", "dockerfile_path": "/a/b/server.Dockerfile", "subdir": "/a/b/server.Dockerfile"}),
({"subdir": "a/b/Dockerfile"}, {"context": "a/b", "dockerfile_path": "a/b/Dockerfile", "subdir": "a/b/Dockerfile"}),
({"subdir": "a/b/server.Dockerfile"},
{"context": "a/b", "dockerfile_path": "a/b/server.Dockerfile", "subdir": "a/b/server.Dockerfile"}),
({"subdir": "/a/b/c", "context": "slime"}, {"context": "slime", "subdir": "/a/b/c"}),
])
def test_super_user_build_endpoints(org_config, expected):
assert _get_config_expand(org_config) == expected