Skip to content

Commit f71e023

Browse files
authored
Require stable API version for submitting an add-on using stable channel (#33)
Currently add-on authors are able to submit stable add-ons to the 2024.1 API. However, the 2024.1 API is not stable yet. If a user attempts to install an add-on that is currently marked as compatible with 2024.1, with the final NVDA 2024.1 release, they will encounter errors. Add-on authors are encouraged to submit add-ons using the "dev" version to NVDA APIs which are not yet released. This PR makes it required for an add-on to use dev or beta channels when submitting an add-on to an API version that is still in development, and is yet to be released. For example: in nvdaAPIVersions.json, 2024.1 will include a flag "experimental": true until RC is reached when submitting an add-on with a "stable" channel to 2024.1, the submission will fail with an error encouraging the submitter to use the beta or dev channel
1 parent e9a231b commit f71e023

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

_tests/testData/nvdaAPIVersions.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,19 @@
3737
"minor": 1,
3838
"patch": 0
3939
}
40+
},
41+
{
42+
"description": "NVDA 2024.1",
43+
"apiVer": {
44+
"major": 2024,
45+
"minor": 1,
46+
"patch": 0
47+
},
48+
"backCompatTo": {
49+
"major": 2024,
50+
"minor": 1,
51+
"patch": 0
52+
},
53+
"experimental": true
4054
}
4155
]

_tests/test_validate.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def test_getExistingVersions(self):
302302
formattedVersions = list(validate.getExistingVersions(self.verFilename))
303303
self.assertEqual(
304304
formattedVersions,
305-
["0.0.0", "2022.1.0", "2023.1.0"]
305+
["0.0.0", "2022.1.0", "2023.1.0", "2024.1.0"]
306306
)
307307

308308

@@ -352,6 +352,29 @@ def test_invalidNew(self):
352352
["Last tested version error: 9999.3.0 doesn't exist"]
353353
)
354354

355+
def test_validExperimental(self):
356+
self.submissionData["lastTestedVersion"]["major"] = 2024
357+
self.submissionData["lastTestedVersion"]["minor"] = 1
358+
self.submissionData["lastTestedVersion"]["patch"] = 0
359+
self.submissionData["channel"] = "beta"
360+
self.assertEqual(
361+
list(validate.checkLastTestedVersionExist(self.submissionData, self.verFilename)),
362+
[]
363+
)
364+
365+
def test_invalidExperimental(self):
366+
self.submissionData["lastTestedVersion"]["major"] = 2024
367+
self.submissionData["lastTestedVersion"]["minor"] = 1
368+
self.submissionData["lastTestedVersion"]["patch"] = 0
369+
self.submissionData["channel"] = "stable"
370+
self.assertEqual(
371+
list(validate.checkLastTestedVersionExist(self.submissionData, self.verFilename)),
372+
[
373+
"Last tested version error: 2024.1.0 is not stable yet. "
374+
"Please submit add-on using the beta or dev channel."
375+
]
376+
)
377+
355378

356379
class validate_checkMinRequiredVersionExists(unittest.TestCase):
357380
"""Test for the checkMinRequiredVersionExists function."""
@@ -399,6 +422,29 @@ def test_invalidNew(self):
399422
["Minimum required version error: 9999.3.0 doesn't exist"]
400423
)
401424

425+
def test_validExperimental(self):
426+
self.submissionData["minNVDAVersion"]["major"] = 2024
427+
self.submissionData["minNVDAVersion"]["minor"] = 1
428+
self.submissionData["minNVDAVersion"]["patch"] = 0
429+
self.submissionData["channel"] = "beta"
430+
self.assertEqual(
431+
list(validate.checkMinRequiredVersionExist(self.submissionData, self.verFilename)),
432+
[]
433+
)
434+
435+
def test_invalidExperimental(self):
436+
self.submissionData["minNVDAVersion"]["major"] = 2024
437+
self.submissionData["minNVDAVersion"]["minor"] = 1
438+
self.submissionData["minNVDAVersion"]["patch"] = 0
439+
self.submissionData["channel"] = "stable"
440+
self.assertEqual(
441+
list(validate.checkMinRequiredVersionExist(self.submissionData, self.verFilename)),
442+
[
443+
"Minimum required version error: 2024.1.0 is not stable yet. "
444+
"Please submit add-on using the beta or dev channel."
445+
]
446+
)
447+
402448

403449
class Validate_checkMinNVDAVersionMatches(unittest.TestCase):
404450
"""Tests for the checkMinNVDAVersionMatches function.

_validate/validate.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,22 @@ def getExistingVersions(verFilename: str) -> List[str]:
5252
"""Loads API versions file and returns list of versions formatted as strings.
5353
"""
5454
with open(verFilename) as f:
55-
data: JsonObjT = json.load(f)
55+
data: List[JsonObjT] = json.load(f)
5656
return [_formatVersionString(version["apiVer"].values()) for version in data]
5757

5858

59+
def getExistingStableVersions(verFilename: str) -> List[str]:
60+
"""Loads API versions file and returns list of stable versions formatted as strings.
61+
"""
62+
with open(verFilename) as f:
63+
data: List[JsonObjT] = json.load(f)
64+
return [
65+
_formatVersionString(version["apiVer"].values())
66+
for version in data
67+
if not version.get("experimental", False)
68+
]
69+
70+
5971
def _validateJson(data: JsonObjT) -> None:
6072
""" Ensure that the loaded metadata conforms to the schema.
6173
Raise error if not
@@ -277,13 +289,27 @@ def checkLastTestedVersionExist(submission: JsonObjT, verFilename: str) -> Valid
277289
if formattedLastTestedVersion not in getExistingVersions(verFilename):
278290
yield f"Last tested version error: {formattedLastTestedVersion} doesn't exist"
279291

292+
elif (
293+
submission["channel"] == "stable"
294+
and formattedLastTestedVersion not in getExistingStableVersions(verFilename)
295+
):
296+
yield f"Last tested version error: {formattedLastTestedVersion} is not stable yet. " + \
297+
"Please submit add-on using the beta or dev channel."
298+
280299

281300
def checkMinRequiredVersionExist(submission: JsonObjT, verFilename: str) -> ValidationErrorGenerator:
282301
minRequiredVersion: JsonObjT = submission["minNVDAVersion"]
283302
formattedMinRequiredVersion: str = _formatVersionString(minRequiredVersion.values())
284303
if formattedMinRequiredVersion not in getExistingVersions(verFilename):
285304
yield f"Minimum required version error: {formattedMinRequiredVersion} doesn't exist"
286305

306+
elif (
307+
submission["channel"] == "stable"
308+
and formattedMinRequiredVersion not in getExistingStableVersions(verFilename)
309+
):
310+
yield f"Minimum required version error: {formattedMinRequiredVersion} is not stable yet. " + \
311+
"Please submit add-on using the beta or dev channel."
312+
287313

288314
def checkVersions(
289315
manifest: AddonManifest,

0 commit comments

Comments
 (0)