c2pa-python 0.39.0__tar.gz → 0.39.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {c2pa_python-0.39.0/src/c2pa_python.egg-info → c2pa_python-0.39.1}/PKG-INFO +6 -4
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/README.md +5 -3
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/pyproject.toml +1 -1
- {c2pa_python-0.39.0 → c2pa_python-0.39.1/src/c2pa_python.egg-info}/PKG-INFO +6 -4
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa_python.egg-info/SOURCES.txt +1 -0
- c2pa_python-0.39.1/tests/test_docs_versions.py +189 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/tests/test_versioned_docs.py +37 -9
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/LICENSE-APACHE +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/LICENSE-MIT +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/MANIFEST.in +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/requirements.txt +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/scripts/download_artifacts.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/setup.cfg +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/setup.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa/__init__.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa/build.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa/c2pa.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa/lib.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa_python.egg-info/dependency_links.txt +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa_python.egg-info/entry_points.txt +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa_python.egg-info/requires.txt +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/src/c2pa_python.egg-info/top_level.txt +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/tests/test_unit_tests.py +0 -0
- {c2pa_python-0.39.0 → c2pa_python-0.39.1}/tests/test_unit_tests_threaded.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: c2pa-python
|
|
3
|
-
Version: 0.39.
|
|
3
|
+
Version: 0.39.1
|
|
4
4
|
Summary: Python bindings for the C2PA Content Authenticity Initiative (CAI) library
|
|
5
5
|
Author-email: Gavin Peacock <gvnpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
|
|
6
6
|
Maintainer-email: Gavin Peacock <gpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
|
|
@@ -121,9 +121,11 @@ See the [`examples` directory](https://github.com/contentauth/c2pa-python/tree/m
|
|
|
121
121
|
|
|
122
122
|
API documentation is published at [github.io/c2pa-python/api/c2pa](https://contentauth.github.io/c2pa-python/api/c2pa/index.html).
|
|
123
123
|
|
|
124
|
-
Use the documentation version dropdown to choose a
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
Use the documentation version dropdown to choose a retained major/minor line.
|
|
125
|
+
`api-docs/versions.json` selects one exact stable patch per line, in numeric descending order;
|
|
126
|
+
the highest line is the default at the existing documentation URL.
|
|
127
|
+
Once the documentation App is configured, stable releases advance retained lines or
|
|
128
|
+
introduce newer lines automatically. Maintenance releases never displace a newer default.
|
|
127
129
|
|
|
128
130
|
To build documentation locally, see [Contributing to the project](https://github.com/contentauth/c2pa-python/blob/main/docs/project-contributions.md#api-reference-documentation).
|
|
129
131
|
|
|
@@ -100,9 +100,11 @@ See the [`examples` directory](https://github.com/contentauth/c2pa-python/tree/m
|
|
|
100
100
|
|
|
101
101
|
API documentation is published at [github.io/c2pa-python/api/c2pa](https://contentauth.github.io/c2pa-python/api/c2pa/index.html).
|
|
102
102
|
|
|
103
|
-
Use the documentation version dropdown to choose a
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
Use the documentation version dropdown to choose a retained major/minor line.
|
|
104
|
+
`api-docs/versions.json` selects one exact stable patch per line, in numeric descending order;
|
|
105
|
+
the highest line is the default at the existing documentation URL.
|
|
106
|
+
Once the documentation App is configured, stable releases advance retained lines or
|
|
107
|
+
introduce newer lines automatically. Maintenance releases never displace a newer default.
|
|
106
108
|
|
|
107
109
|
To build documentation locally, see [Contributing to the project](https://github.com/contentauth/c2pa-python/blob/main/docs/project-contributions.md#api-reference-documentation).
|
|
108
110
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "c2pa-python"
|
|
7
|
-
version = "0.39.
|
|
7
|
+
version = "0.39.1"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
9
|
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
|
|
10
10
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: c2pa-python
|
|
3
|
-
Version: 0.39.
|
|
3
|
+
Version: 0.39.1
|
|
4
4
|
Summary: Python bindings for the C2PA Content Authenticity Initiative (CAI) library
|
|
5
5
|
Author-email: Gavin Peacock <gvnpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
|
|
6
6
|
Maintainer-email: Gavin Peacock <gpeacock@adobe.com>, Tania Mathern <mathern@adobe.com>
|
|
@@ -121,9 +121,11 @@ See the [`examples` directory](https://github.com/contentauth/c2pa-python/tree/m
|
|
|
121
121
|
|
|
122
122
|
API documentation is published at [github.io/c2pa-python/api/c2pa](https://contentauth.github.io/c2pa-python/api/c2pa/index.html).
|
|
123
123
|
|
|
124
|
-
Use the documentation version dropdown to choose a
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
Use the documentation version dropdown to choose a retained major/minor line.
|
|
125
|
+
`api-docs/versions.json` selects one exact stable patch per line, in numeric descending order;
|
|
126
|
+
the highest line is the default at the existing documentation URL.
|
|
127
|
+
Once the documentation App is configured, stable releases advance retained lines or
|
|
128
|
+
introduce newer lines automatically. Maintenance releases never displace a newer default.
|
|
127
129
|
|
|
128
130
|
To build documentation locally, see [Contributing to the project](https://github.com/contentauth/c2pa-python/blob/main/docs/project-contributions.md#api-reference-documentation).
|
|
129
131
|
|
|
@@ -16,6 +16,7 @@ src/c2pa_python.egg-info/dependency_links.txt
|
|
|
16
16
|
src/c2pa_python.egg-info/entry_points.txt
|
|
17
17
|
src/c2pa_python.egg-info/requires.txt
|
|
18
18
|
src/c2pa_python.egg-info/top_level.txt
|
|
19
|
+
tests/test_docs_versions.py
|
|
19
20
|
tests/test_unit_tests.py
|
|
20
21
|
tests/test_unit_tests_threaded.py
|
|
21
22
|
tests/test_versioned_docs.py
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import copy
|
|
3
|
+
import json
|
|
4
|
+
import unittest
|
|
5
|
+
from unittest.mock import patch
|
|
6
|
+
from urllib.error import HTTPError
|
|
7
|
+
|
|
8
|
+
from scripts.docs_versions import promote, validate_manifest
|
|
9
|
+
from scripts import promote_docs_release as writer
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def selection():
|
|
13
|
+
return {
|
|
14
|
+
"versions": ["v1.10.2", "v1.9.4"],
|
|
15
|
+
"retiredLines": ["0.38"],
|
|
16
|
+
"aliases": {"v1.10.2": "1.10", "v1.9.4": "1.9", "v1.9.0": "1.9"},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DocsVersionTests(unittest.TestCase):
|
|
21
|
+
def test_patch_promotion_is_idempotent_and_preserves_aliases(self):
|
|
22
|
+
original = selection()
|
|
23
|
+
updated = promote(original, "v1.9.5")
|
|
24
|
+
self.assertEqual(updated["versions"], ["v1.10.2", "v1.9.5"])
|
|
25
|
+
self.assertEqual(updated["aliases"]["v1.9.4"], "1.9")
|
|
26
|
+
self.assertEqual(updated["aliases"]["v1.9.5"], "1.9")
|
|
27
|
+
self.assertEqual(promote(updated, "v1.9.5"), updated)
|
|
28
|
+
self.assertEqual(promote(updated, "v1.9.3"), updated)
|
|
29
|
+
self.assertEqual(original, selection())
|
|
30
|
+
|
|
31
|
+
def test_new_lines_sort_numerically_without_resurrecting_retired_lines(self):
|
|
32
|
+
self.assertEqual(promote(selection(), "v0.38.99"), selection())
|
|
33
|
+
self.assertEqual(
|
|
34
|
+
promote(selection(), "v2.0.0")["versions"],
|
|
35
|
+
["v2.0.0", "v1.10.2", "v1.9.4"],
|
|
36
|
+
)
|
|
37
|
+
self.assertEqual(promote(selection(), "v1.8.9"), selection())
|
|
38
|
+
retired_future = selection()
|
|
39
|
+
retired_future["retiredLines"].append("3.0")
|
|
40
|
+
self.assertEqual(promote(retired_future, "v2.0.0"), retired_future)
|
|
41
|
+
|
|
42
|
+
def test_invalid_manifests_and_release_tags_fail(self):
|
|
43
|
+
bad = []
|
|
44
|
+
for versions in [
|
|
45
|
+
[], ["v1.9.4", "v1.10.2"], ["v1.10.2", "v1.10.1"],
|
|
46
|
+
["v1.0.0-rc.1"], ["v01.0.0"], ["1.0.0"], [None],
|
|
47
|
+
]:
|
|
48
|
+
config = selection()
|
|
49
|
+
config["versions"] = versions
|
|
50
|
+
bad.append(config)
|
|
51
|
+
for field, value in [
|
|
52
|
+
("retiredLines", ["1.10"]), ("retiredLines", ["0.38", "0.38"]),
|
|
53
|
+
("retiredLines", ["v0.38"]), ("retiredLines", "0.38"),
|
|
54
|
+
("aliases", []), ("aliases", {"../escape": "1.9"}),
|
|
55
|
+
("aliases", {"v1.9.4": "1.10"}), ("aliases", {"v0.38.0": "0.38"}),
|
|
56
|
+
("aliases", {"v1.9.5": "1.9"}), ("aliases", {}),
|
|
57
|
+
]:
|
|
58
|
+
config = selection()
|
|
59
|
+
config[field] = value
|
|
60
|
+
bad.append(config)
|
|
61
|
+
for config in bad:
|
|
62
|
+
with self.subTest(config=config), self.assertRaises(ValueError):
|
|
63
|
+
validate_manifest(config)
|
|
64
|
+
for tag in ["v2.0.0-rc.1", "v2.0.0+build", "../main"]:
|
|
65
|
+
with self.subTest(tag=tag), self.assertRaises(ValueError):
|
|
66
|
+
promote(selection(), tag)
|
|
67
|
+
|
|
68
|
+
@patch.object(writer, "api")
|
|
69
|
+
@patch.object(writer.time, "sleep")
|
|
70
|
+
def test_conflict_recomputes_from_live_manifest_and_only_writes_allowlisted_file(self, sleep, api):
|
|
71
|
+
concurrent = promote(selection(), "v2.0.0")
|
|
72
|
+
|
|
73
|
+
def encoded(config, sha):
|
|
74
|
+
return {"content": base64.b64encode(json.dumps(config).encode()).decode(), "sha": sha}
|
|
75
|
+
|
|
76
|
+
conflict = HTTPError("url", 409, "conflict", {}, None)
|
|
77
|
+
self.addCleanup(conflict.close)
|
|
78
|
+
api.side_effect = [
|
|
79
|
+
{"id": 123, "tag_name": "v1.9.5", "draft": False,
|
|
80
|
+
"prerelease": False, "published_at": "2026-01-01"},
|
|
81
|
+
[],
|
|
82
|
+
encoded(selection(), "first"),
|
|
83
|
+
conflict,
|
|
84
|
+
encoded(concurrent, "second"),
|
|
85
|
+
{"commit": {"sha": "committed"}},
|
|
86
|
+
]
|
|
87
|
+
writer.promote_release("v1.9.5", "123", "read", "write")
|
|
88
|
+
writes = [call for call in api.call_args_list if call.args[0] == "PUT"]
|
|
89
|
+
self.assertEqual(len(writes), 2)
|
|
90
|
+
for call in writes:
|
|
91
|
+
self.assertEqual(call.args[1:3], ("contents/api-docs/versions.json", "write"))
|
|
92
|
+
payload = writes[-1].args[3]
|
|
93
|
+
self.assertEqual(payload["sha"], "second")
|
|
94
|
+
self.assertEqual(payload["branch"], "main")
|
|
95
|
+
updated = json.loads(base64.b64decode(payload["content"]))
|
|
96
|
+
self.assertEqual(updated["versions"], ["v2.0.0", "v1.10.2", "v1.9.5"])
|
|
97
|
+
|
|
98
|
+
@patch.object(writer, "api")
|
|
99
|
+
def test_release_metadata_must_match_event_before_any_manifest_access(self, api):
|
|
100
|
+
valid = {"id": 123, "tag_name": "v1.9.5", "draft": False,
|
|
101
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
102
|
+
for key, value in [
|
|
103
|
+
("id", 456), ("tag_name", "v1.9.4"), ("draft", True),
|
|
104
|
+
("prerelease", True), ("published_at", None),
|
|
105
|
+
]:
|
|
106
|
+
release = copy.deepcopy(valid)
|
|
107
|
+
release[key] = value
|
|
108
|
+
api.reset_mock()
|
|
109
|
+
api.return_value = release
|
|
110
|
+
with self.subTest(key=key), self.assertRaises(ValueError):
|
|
111
|
+
writer.promote_release("v1.9.5", "123", "read", "write")
|
|
112
|
+
self.assertEqual(api.call_count, 1)
|
|
113
|
+
|
|
114
|
+
@patch.object(writer, "api")
|
|
115
|
+
@patch.object(writer.time, "sleep")
|
|
116
|
+
def test_retries_are_bounded_and_permission_errors_fail_immediately(self, sleep, api):
|
|
117
|
+
release = {"id": 123, "tag_name": "v1.9.5", "draft": False,
|
|
118
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
119
|
+
current = {"content": base64.b64encode(json.dumps(selection()).encode()).decode(), "sha": "sha"}
|
|
120
|
+
for code, attempts in [(403, 1), (409, 5)]:
|
|
121
|
+
api.reset_mock()
|
|
122
|
+
error = HTTPError("url", code, "failure", {}, None)
|
|
123
|
+
self.addCleanup(error.close)
|
|
124
|
+
api.side_effect = [release, []] + [item for _ in range(attempts) for item in (current, error)]
|
|
125
|
+
with self.subTest(code=code), self.assertRaises(HTTPError):
|
|
126
|
+
writer.promote_release("v1.9.5", "123", "read", "write")
|
|
127
|
+
self.assertEqual(api.call_count, 2 + attempts * 2)
|
|
128
|
+
|
|
129
|
+
@patch.object(writer, "api")
|
|
130
|
+
def test_release_burst_reconciliation_preserves_selection_and_ignores_historical_lines(self, api):
|
|
131
|
+
release = {"id": 123, "tag_name": "v1.9.5", "draft": False,
|
|
132
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
133
|
+
releases = [
|
|
134
|
+
dict(release, tag_name=tag) for tag in
|
|
135
|
+
["v1.9.6", "v2.0.0", "v2.0.1", "v1.8.7", "v0.38.99", "v3.0.0-rc.1"]
|
|
136
|
+
]
|
|
137
|
+
releases.append(dict(release, tag_name="v4.0.0", prerelease=True))
|
|
138
|
+
current = {"content": base64.b64encode(json.dumps(selection()).encode()).decode(), "sha": "sha"}
|
|
139
|
+
api.side_effect = [release, releases, current, {}]
|
|
140
|
+
writer.promote_release("v1.9.5", "123", "read", "write")
|
|
141
|
+
payload = api.call_args_list[-1].args[3]
|
|
142
|
+
updated = json.loads(base64.b64decode(payload["content"]))
|
|
143
|
+
self.assertEqual(updated["versions"], ["v2.0.1", "v1.10.2", "v1.9.6"])
|
|
144
|
+
self.assertNotIn("v1.8.7", updated["aliases"])
|
|
145
|
+
|
|
146
|
+
@patch.object(writer, "api")
|
|
147
|
+
def test_unchanged_reconciliation_never_writes(self, api):
|
|
148
|
+
release = {"id": 123, "tag_name": "v1.9.4", "draft": False,
|
|
149
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
150
|
+
current = {"content": base64.b64encode(json.dumps(selection()).encode()).decode(), "sha": "sha"}
|
|
151
|
+
api.side_effect = [release, [], current]
|
|
152
|
+
writer.promote_release("v1.9.4", "123", "read", "write")
|
|
153
|
+
self.assertEqual(api.call_count, 3)
|
|
154
|
+
|
|
155
|
+
@patch.object(writer, "api")
|
|
156
|
+
def test_release_reconciliation_reads_all_pages(self, api):
|
|
157
|
+
release = {"id": 123, "tag_name": "v1.9.4", "draft": False,
|
|
158
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
159
|
+
current = {"content": base64.b64encode(json.dumps(selection()).encode()).decode(), "sha": "sha"}
|
|
160
|
+
api.side_effect = [
|
|
161
|
+
release, [release] * 100, [dict(release, tag_name="v2.0.0")], current, {},
|
|
162
|
+
]
|
|
163
|
+
writer.promote_release("v1.9.4", "123", "read", "write")
|
|
164
|
+
self.assertEqual(api.call_args_list[2].args[1], "releases?per_page=100&page=2")
|
|
165
|
+
updated = json.loads(base64.b64decode(api.call_args_list[-1].args[3]["content"]))
|
|
166
|
+
self.assertEqual(updated["versions"][0], "v2.0.0")
|
|
167
|
+
|
|
168
|
+
@patch.object(writer, "api")
|
|
169
|
+
@patch.object(writer.time, "sleep")
|
|
170
|
+
def test_concurrent_human_retirement_is_not_reversed(self, sleep, api):
|
|
171
|
+
release = {"id": 123, "tag_name": "v1.9.5", "draft": False,
|
|
172
|
+
"prerelease": False, "published_at": "2026-01-01"}
|
|
173
|
+
retired = selection()
|
|
174
|
+
retired["versions"].remove("v1.9.4")
|
|
175
|
+
retired["retiredLines"].append("1.9")
|
|
176
|
+
retired["aliases"] = {"v1.10.2": "1.10"}
|
|
177
|
+
|
|
178
|
+
def encoded(config):
|
|
179
|
+
return {"content": base64.b64encode(json.dumps(config).encode()).decode(), "sha": "sha"}
|
|
180
|
+
|
|
181
|
+
conflict = HTTPError("url", 409, "conflict", {}, None)
|
|
182
|
+
self.addCleanup(conflict.close)
|
|
183
|
+
api.side_effect = [release, [], encoded(selection()), conflict, encoded(retired)]
|
|
184
|
+
writer.promote_release("v1.9.5", "123", "read", "write")
|
|
185
|
+
self.assertEqual(sum(call.args[0] == "PUT" for call in api.call_args_list), 1)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
if __name__ == "__main__":
|
|
189
|
+
unittest.main()
|
|
@@ -12,13 +12,21 @@ from unittest.mock import Mock, patch
|
|
|
12
12
|
import zipfile
|
|
13
13
|
|
|
14
14
|
from scripts import generate_versioned_api_docs as docs
|
|
15
|
+
from scripts.docs_versions import release_line
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def manifest(versions):
|
|
19
|
+
return {
|
|
20
|
+
"versions": versions, "retiredLines": [],
|
|
21
|
+
"aliases": {tag: release_line(tag) for tag in versions},
|
|
22
|
+
}
|
|
15
23
|
|
|
16
24
|
|
|
17
25
|
class VersionedDocsTests(unittest.TestCase):
|
|
18
26
|
def test_version_list_preserves_default_and_order(self):
|
|
19
27
|
with tempfile.TemporaryDirectory() as directory:
|
|
20
28
|
config = Path(directory) / "versions.json"
|
|
21
|
-
config.write_text(
|
|
29
|
+
config.write_text(json.dumps(manifest(["v0.38.0", "v0.37.0"])))
|
|
22
30
|
self.assertEqual(docs.load_versions(config), ["v0.38.0", "v0.37.0"])
|
|
23
31
|
|
|
24
32
|
def test_invalid_versions_are_rejected(self):
|
|
@@ -30,7 +38,9 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
30
38
|
config = Path(directory) / "versions.json"
|
|
31
39
|
for versions in invalid:
|
|
32
40
|
with self.subTest(versions=versions):
|
|
33
|
-
config.write_text(json.dumps({
|
|
41
|
+
config.write_text(json.dumps({
|
|
42
|
+
"versions": versions, "retiredLines": [], "aliases": {},
|
|
43
|
+
}))
|
|
34
44
|
with self.assertRaises(ValueError):
|
|
35
45
|
docs.load_versions(config)
|
|
36
46
|
for value in [[], {}, {"versions": "v0.38.0"}]:
|
|
@@ -43,7 +53,10 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
43
53
|
def test_published_release_is_verified(self, get):
|
|
44
54
|
get.return_value = Mock(
|
|
45
55
|
status_code=200,
|
|
46
|
-
json=Mock(return_value={
|
|
56
|
+
json=Mock(return_value={
|
|
57
|
+
"tag_name": "v0.38.0", "draft": False, "prerelease": False,
|
|
58
|
+
"published_at": "2026-01-01T00:00:00Z",
|
|
59
|
+
}),
|
|
47
60
|
)
|
|
48
61
|
docs.verify_release("v0.38.0")
|
|
49
62
|
get.assert_called_once_with(
|
|
@@ -123,7 +136,7 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
123
136
|
|
|
124
137
|
def test_switcher_links_resolve_from_root_and_nested_version_pages(self):
|
|
125
138
|
versions = ["v0.38.0", "v0.37.0"]
|
|
126
|
-
for prefix in ["", "versions/
|
|
139
|
+
for prefix in ["", "versions/0.38", "versions/0.37"]:
|
|
127
140
|
with self.subTest(prefix=prefix), patch.dict(
|
|
128
141
|
os.environ,
|
|
129
142
|
{
|
|
@@ -140,7 +153,7 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
140
153
|
for item in context["docs_versions"]:
|
|
141
154
|
self.assertEqual(
|
|
142
155
|
posixpath.normpath(posixpath.join(parent, item["url"])),
|
|
143
|
-
f"versions/{item['
|
|
156
|
+
f"versions/{item['line']}/index.html",
|
|
144
157
|
)
|
|
145
158
|
|
|
146
159
|
@patch.dict(os.environ, {}, clear=True)
|
|
@@ -167,7 +180,7 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
167
180
|
root = Path(directory)
|
|
168
181
|
(root / "api-docs").mkdir()
|
|
169
182
|
(root / "api-docs/versions.json").write_text(
|
|
170
|
-
|
|
183
|
+
json.dumps(manifest(["v0.38.0", "v0.37.0"]))
|
|
171
184
|
)
|
|
172
185
|
(root / "scripts").mkdir()
|
|
173
186
|
(root / "scripts/generate_api_docs.py").touch()
|
|
@@ -176,8 +189,8 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
176
189
|
self.assertEqual((site / "index.html").read_text(), "v0.38.0:")
|
|
177
190
|
for tag in ["v0.38.0", "v0.37.0"]:
|
|
178
191
|
self.assertEqual(
|
|
179
|
-
(site / "versions" / tag / "index.html").read_text(),
|
|
180
|
-
f"{tag}:versions/{tag}",
|
|
192
|
+
(site / "versions" / release_line(tag) / "index.html").read_text(),
|
|
193
|
+
f"{tag}:versions/{release_line(tag)}",
|
|
181
194
|
)
|
|
182
195
|
self.assertTrue((site / ".nojekyll").is_file())
|
|
183
196
|
self.assertEqual(list((root / "api-docs/_build").iterdir()), [site])
|
|
@@ -195,7 +208,9 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
195
208
|
site = root / "api-docs/_build/versioned"
|
|
196
209
|
site.mkdir(parents=True)
|
|
197
210
|
(site / "index.html").write_text("previous site")
|
|
198
|
-
(root / "api-docs/versions.json").write_text(
|
|
211
|
+
(root / "api-docs/versions.json").write_text(
|
|
212
|
+
json.dumps(manifest(["v0.38.0"]))
|
|
213
|
+
)
|
|
199
214
|
(root / "scripts").mkdir()
|
|
200
215
|
(root / "scripts/generate_api_docs.py").touch()
|
|
201
216
|
with patch.object(docs, "ROOT", root):
|
|
@@ -204,6 +219,19 @@ class VersionedDocsTests(unittest.TestCase):
|
|
|
204
219
|
self.assertEqual((site / "index.html").read_text(), "previous site")
|
|
205
220
|
self.assertEqual(list((root / "api-docs/_build").iterdir()), [site])
|
|
206
221
|
|
|
222
|
+
def test_legacy_html_redirects_preserve_equivalent_suffix_and_fragment(self):
|
|
223
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
224
|
+
site = Path(directory)
|
|
225
|
+
page = site / "versions/0.38/api/c2pa/index.html"
|
|
226
|
+
page.parent.mkdir(parents=True)
|
|
227
|
+
page.write_text("current")
|
|
228
|
+
docs.write_aliases(site, {"v0.38.1": "0.38"})
|
|
229
|
+
redirect = site / "versions/v0.38.1/api/c2pa/index.html"
|
|
230
|
+
text = redirect.read_text()
|
|
231
|
+
self.assertIn("../../../0.38/api/c2pa/index.html", text)
|
|
232
|
+
self.assertIn("+location.search+location.hash", text)
|
|
233
|
+
self.assertFalse((redirect.parent / "removed.html").exists())
|
|
234
|
+
|
|
207
235
|
|
|
208
236
|
if __name__ == "__main__":
|
|
209
237
|
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|