FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-github-backup/tests/test_releases.py at master · dumpmemory/python-github-backup · GitHub
dumpmemory
/
python-github-backup
Public
forked from
josegonzalez/python-github-backup
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-github-backup
/
tests
/
test_releases.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
95 lines (81 loc) · 3.36 KB
Breadcrumbs
python-github-backup
/
tests
/
test_releases.py
Copy path
File metadata and controls
95 lines (81 loc) · 3.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""Tests for release backup behavior."""
from
github_backup
import
github_backup
def
test_backup_releases_uses_embedded_assets_without_extra_asset_list_request
(
create_args
,
tmp_path
,
monkeypatch
):
args
=
create_args
(
include_releases
=
True
,
include_assets
=
True
)
repository
=
{
"full_name"
:
"owner/repo"
,
"name"
:
"repo"
}
calls
=
[]
downloads
=
[]
def
fake_retrieve_data
(
passed_args
,
template
,
query_args
=
None
,
paginated
=
True
,
**
kwargs
):
calls
.
append
(
template
)
if
template
==
"https://api.github.com/repos/owner/repo/releases"
:
return
[
{
"tag_name"
:
"v1.0.0"
,
"created_at"
:
"2026-01-01T00:00:00Z"
,
"updated_at"
:
"2026-01-01T00:00:00Z"
,
"prerelease"
:
False
,
"draft"
:
False
,
"assets_url"
:
"https://api.github.com/repos/owner/repo/releases/1/assets"
,
"assets"
: [
{
"name"
:
"artifact.zip"
,
"url"
:
"https://api.github.com/repos/owner/repo/releases/assets/1"
,
}
],
}
]
raise
AssertionError
(
"Unexpected API request: {0}"
.
format
(
template
))
def
fake_download_file
(
url
,
path
,
auth
,
as_app
=
False
,
fine
=
False
):
downloads
.
append
((
url
,
path
))
monkeypatch
.
setattr
(
github_backup
,
"retrieve_data"
,
fake_retrieve_data
)
monkeypatch
.
setattr
(
github_backup
,
"download_file"
,
fake_download_file
)
github_backup
.
backup_releases
(
args
,
tmp_path
,
repository
,
"https://api.github.com/repos"
,
include_assets
=
True
,
)
assert
calls
==
[
"https://api.github.com/repos/owner/repo/releases"
]
assert
downloads
==
[
(
"https://api.github.com/repos/owner/repo/releases/assets/1"
,
str
(
tmp_path
/
"releases"
/
"v1.0.0"
/
"artifact.zip"
),
)
]
def
test_backup_releases_falls_back_to_assets_url_when_assets_missing
(
create_args
,
tmp_path
,
monkeypatch
):
args
=
create_args
(
include_releases
=
True
,
include_assets
=
True
)
repository
=
{
"full_name"
:
"owner/repo"
,
"name"
:
"repo"
}
calls
=
[]
def
fake_retrieve_data
(
passed_args
,
template
,
query_args
=
None
,
paginated
=
True
,
**
kwargs
):
calls
.
append
(
template
)
if
template
==
"https://api.github.com/repos/owner/repo/releases"
:
return
[
{
"tag_name"
:
"v1.0.0"
,
"created_at"
:
"2026-01-01T00:00:00Z"
,
"updated_at"
:
"2026-01-01T00:00:00Z"
,
"prerelease"
:
False
,
"draft"
:
False
,
"assets_url"
:
"https://api.github.com/repos/owner/repo/releases/1/assets"
,
}
]
if
template
==
"https://api.github.com/repos/owner/repo/releases/1/assets"
:
return
[]
raise
AssertionError
(
"Unexpected API request: {0}"
.
format
(
template
))
monkeypatch
.
setattr
(
github_backup
,
"retrieve_data"
,
fake_retrieve_data
)
github_backup
.
backup_releases
(
args
,
tmp_path
,
repository
,
"https://api.github.com/repos"
,
include_assets
=
True
,
)
assert
calls
==
[
"https://api.github.com/repos/owner/repo/releases"
,
"https://api.github.com/repos/owner/repo/releases/1/assets"
,
]
Back
|
FazBrowse Home
|
New Git URL