Skip to content
Permalink
Browse files

Allow add-on API version strings to exclude Minor, defaulting to 0. (#…

…9331)

* The Minor part of an Addon's minimumNVDAVersion or lastTestedNVDAVersion is now optional and defaults to 0. E.g. It is now valid to write 2019.1 rather than having to write 2019.1.0.

* Update what's new.

* Fix unit tests to handle the fact that add-on API versions can omit their Minor part.

* Apply suggestions from code review

Co-Authored-By: michaelDCurran <michaelDCurran@users.noreply.github.com>

* Fix typo

Co-Authored-By: michaelDCurran <michaelDCurran@users.noreply.github.com>
  • Loading branch information...
michaelDCurran committed Feb 28, 2019
1 parent 87e09a1 commit 5fbd648a077713d3e4aaf973c4a170a9ad75a43e
@@ -669,13 +669,13 @@ Otherwise, the add-on will not install.
- url: A URL where this add-on, further info and upgrades can be found.
- docFileName: The name of the main documentation file for this add-on; e.g. readme.html. See the [Add-on Documentation #AddonDoc] section for more details.
- minimumNVDAVersion: The minimum required version of NVDA for this add-on to be installed or enabled.
- e.g "2019.1.0"
- Must be a three part version string I.E. Year.Minor.Minor. Two part version strings ("2019.1") will not pass validation.
- e.g "2019.1.1"
- Must be a three part version string I.E. Year.Major.Minor, or a two part version string of Year.Major. In the second case, Minor defaults to 0.
- Defaults to "0.0.0"
- Must be less than or equal to `lastTestedNVDAVersion`
- lastTestedNVDAVersion: The last version of NVDA this add-on has been tested with.
- e.g "2019.1.0"
- Must be a three part version string I.E. Year.Minor.Minor. Two part version strings ("2019.1") will not pass validation.
- Must be a three part version string I.E. Year.Major.Minor, or a two part version string of Year.Major. In the second case, Minor defaults to 0.
- Defaults to "0.0.0"
- Must be greater than or equal to `minimumNVDAVersion`
-
@@ -23,11 +23,12 @@

#: Compiled regular expression to match an addon API version string.
#: Supports year.major.minor versions (e.g. 2018.1.1).
# Although year and major are mandatory, minor is optional.
#: Resulting match objects expose three groups reflecting release year, release major, and release minor version,
# respectively.
# As minor is optional, the final group in the resulting match object may be None if minor is not provided in the original string. In this case it should be treated as being 0.
#: @type: RegexObject
ADDON_API_VERSION_REGEX = re.compile(r"^(0|\d{4})\.(\d)\.(\d)$")

ADDON_API_VERSION_REGEX = re.compile(r"^(0|\d{4})\.(\d)(?:\.(\d))?$")

def getAPIVersionTupleFromString(version):
"""Converts a string containing an NVDA version to a tuple of the form (versionYear, versionMajor, versionMinor)"""
@@ -657,7 +657,8 @@ class AddonManifest(ConfigObj):
# Eg: 2019.1.0 or 0.0.0
# Must have 3 integers separated by dots.
# The first integer must be a Year (4 characters)
# "0.0.0" is also valid
# "0.0.0" is also valid.
# The final integer can be left out, and in that case will default to 0. E.g. 2019.1
"""))

@@ -88,12 +88,18 @@ def test_addonCompat_attemptingToUseAddonRequiringNewAPIFeaturesWithOldNVDA(self

class TestGetAPIVersionTupleFromString(unittest.TestCase):

def test_getAPIVersionTupleFromString_succeeds(self):
def test_getAPIVersionTupleFromString_3_succeeds(self):
"""Tests trying to get the API version tuple from an API version string with a standard version
layout will succeed.
"""
self.assertEqual((2019, 1, 0), addonAPIVersion.getAPIVersionTupleFromString("2019.1.0"))

def test_getAPIVersionTupleFromString_2_succeeds(self):
"""Tests trying to get the API version tuple from an API version where the Minor part is omitted and therefore defaults to 0.
This will succeed.
"""
self.assertEqual((2019, 1, 0), addonAPIVersion.getAPIVersionTupleFromString("2019.1"))

def test_getAPIVersionTupleFromString_allZeros_succeeds(self):
"""Tests trying to get the API version tuple from an API version string that is all zeros.
This is used as the FIRST api version.
@@ -124,12 +130,6 @@ def test_getAPIVersionTupleFromString_oneMatch_raises(self):
"""
self.assertRaises(ValueError, addonAPIVersion.getAPIVersionTupleFromString, "2019.")

def test_getAPIVersionTupleFromString_twoMatch_raises(self):
"""Tests trying to get the API version tuple from an API version string with two matching groups
results in an error being raised
"""
self.assertRaises(ValueError, addonAPIVersion.getAPIVersionTupleFromString, "2019.1")

def test_getAPIVersionTupleFromString_devAppended_raises(self):
"""Tests trying to get the API version tuple from an API version string with three matching groups
and some extra appended results in an error being raised
@@ -23,8 +23,9 @@ What's New in NVDA

== Changes ==
- Updated liblouis braille translator to version 3.8.0. (#9013)
- Add-on authors now can enforce a minimum required NVDA version for their add-ons. Unsupported add-ons will not load or install. (#6275)
- Add-on authors must now specify the last version of NVDA the add-on has been tested against. Users will be warned against installing or enabling untested add-ons. (#6275)
- Add-on authors now can enforce a minimum required NVDA version for their add-ons. NVDA will refuse to install or load an add-on whose minimum required NVDA version is higher than the current NVDA version. (#6275)
- Add-on authors can now specify the last version of NVDA the add-on has been tested against. If an add-on has been only tested against a version of NVDA lower than the current version, then NVDA will refuse to install or load the add-on. (#6275)
- This version of NVDA will allow installing and loading of add-ons that do not yet contain Minimum and Last Tested NVDA version information, but upgrading to future versions of NVDA (E.g. 2019.2) may automatically cause these older add-ons to be disabled.
- The move mouse to navigator object command is now available in Microsoft Word as well as for UIA controls, particularly Microsoft Edge. (#7916, #8371)
- Reporting of text under the mouse has been improved within Microsoft Edge and other UIA applications. (#8370)
- When NVDA is started with the `--portable-path` command line parameter, the provided path is automatically filled in when trying to create a portable copy of NVDA using the NVDA menu. (#8623)

0 comments on commit 5fbd648

Please sign in to comment.
You can’t perform that action at this time.