def test_wrap_name_from_git(prefix, expected_prefix, suffix, expected_suffix): repo = 'repo' branch = 'branch' hash_size = 5 # Amount of separators when joining all segments: # repo, branch, hash, prefix, suffix num_separators = 4 limit = len(suffix) + len(prefix) + hash_size + num_separators bc_name = wrap_name_from_git(prefix, suffix, repo, branch, limit=limit, hash_size=hash_size) assert bc_name.startswith(expected_prefix + '-') assert bc_name.endswith('-' + expected_suffix) assert len(bc_name) <= limit # Is this a valid name for OpenShift to use? valid = re.compile(BC_NAME_REGEX) assert valid.match(bc_name)