|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 | #
|
3 |
| -# Copyright (C) 2023 CERN. |
| 3 | +# Copyright (C) 2023-2024 CERN. |
4 | 4 | #
|
5 | 5 | # Invenio-Github is free software; you can redistribute it and/or modify
|
6 | 6 | # it under the terms of the MIT License; see LICENSE file for more details.
|
@@ -78,3 +78,43 @@ def test_release_api(app, test_user, github_api):
|
78 | 78 |
|
79 | 79 | assert valid_remote_file_contents is not None
|
80 | 80 | assert valid_remote_file_contents.decoded["name"] == "test.py"
|
| 81 | + |
| 82 | + |
| 83 | +def test_test_zipball(app, test_user, github_api): |
| 84 | + api = GitHubAPI(test_user.id) |
| 85 | + api.init_account() |
| 86 | + repo_id = 2 |
| 87 | + repo_name = "repo-2" |
| 88 | + |
| 89 | + # Create a repo hook |
| 90 | + hook_created = api.create_hook(repo_id=repo_id, repo_name=repo_name) |
| 91 | + assert hook_created |
| 92 | + |
| 93 | + headers = [("Content-Type", "application/json")] |
| 94 | + |
| 95 | + payload = github_payload_fixture( |
| 96 | + "auser", repo_name, repo_id, tag="v1.0-tag-and-branch" |
| 97 | + ) |
| 98 | + with app.test_request_context(headers=headers, data=json.dumps(payload)): |
| 99 | + event = Event.create( |
| 100 | + receiver_id="github", |
| 101 | + user_id=test_user.id, |
| 102 | + ) |
| 103 | + release = Release( |
| 104 | + release_id=payload["release"]["id"], |
| 105 | + tag=event.payload["release"]["tag_name"], |
| 106 | + repository_id=repo_id, |
| 107 | + event=event, |
| 108 | + status=ReleaseStatus.RECEIVED, |
| 109 | + ) |
| 110 | + # Idea is to test the public interface of GithubRelease |
| 111 | + gh = GitHubRelease(release) |
| 112 | + |
| 113 | + # Call the method fixing the zipball URL |
| 114 | + gh.test_zipball() |
| 115 | + |
| 116 | + # Check that the zipball URL is the alternate URL specific for tags |
| 117 | + assert ( |
| 118 | + gh.release_zipball_url |
| 119 | + == "https://github.com/auser/repo-2/zipball/refs/tags/v1.0-tag-and-branch" |
| 120 | + ) |
0 commit comments