def control_latest_release(): host = get_host() api_token = get_api_token() artifact_sha = get_artifact_sha() project_config_file = parse_cmd_line() with open(project_config_file) as json_data_file: project_data = load_project_configuration(json_data_file) url = ApiSchema.url_for_release(host, project_data, "latest") release = http_get_json(url, api_token) if release["target_artifact"] != artifact_sha: print(f"INCOMPLIANT: latest release {release['release_number']}") print(f" released sha: {release['target_artifact']} ") print(f" expected sha: {artifact_sha} ") sys.exit(1) else: print(f"COMPLIANT: latest release {release['release_number']}") print(f" released sha: {release['target_artifact']} ") print(f" expected sha: {artifact_sha} ")
def test_url_for_release(): partial_project_data = {"name": "hadroncollider", "owner": "cern"} url = ApiSchema.url_for_release(host="http://localhost", project_data=partial_project_data, release_number="12") assert url == "http://localhost/api/v1/projects/cern/hadroncollider/releases/12"