diff --git a/_tests/test_validate.py b/_tests/test_validate.py index bc5d82b..59ddf73 100644 --- a/_tests/test_validate.py +++ b/_tests/test_validate.py @@ -224,6 +224,22 @@ def test_valid(self): errors ) + @patch('os.path.basename', return_value="valid1-Addon_id") + def test_valid_withSymbols(self, mock_basename): + """ Error when submission does not include correct addonId format + """ + self.submissionData['addonId'] = "valid1-Addon_id" + self.manifest['name'] = "valid1-Addon_id" + errors = list( + validate.checkAddonId(self.manifest, VALID_SUBMISSION_JSON_FILE, self.submissionData) + ) + + self.assertEqual( + [ # expected errors + ], + errors + ) + def test_invalidPath(self): """ Error when submission path does not include correct addon ID """ @@ -296,7 +312,7 @@ def test_invalidAddonIdFormat_spaces(self, mock_basename): [ # expected errors "Submission data 'addonId' field does not match the expected format:" " must start and end with a letter, and contain only letters," - " numbers, and hyphens. " + " numbers, underscores, and hyphens. " "ID: invalid addon id" ], errors @@ -316,7 +332,7 @@ def test_invalidAddonIdFormat_invalidStartChar(self, mock_basename): [ # expected errors "Submission data 'addonId' field does not match the expected format:" " must start and end with a letter, and contain only letters," - " numbers, and hyphens. " + " numbers, underscores, and hyphens. " "ID: 1invalid-addon-id" ], errors diff --git a/_validate/validate.py b/_validate/validate.py index 2011bc8..17cd2d7 100644 --- a/_validate/validate.py +++ b/_validate/validate.py @@ -180,11 +180,11 @@ def checkAddonId( "Submission data 'addonId' field does not match 'name' field in addon manifest:" f" {expectedName} vs {submission['addonId']}" ) - if not re.match(r"^[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]$", expectedName): + if not re.match(r"^[A-Za-z][A-Za-z0-9\-_]*[A-Za-z0-9]$", expectedName): yield ( "Submission data 'addonId' field does not match the expected format:" " must start and end with a letter, and contain only letters," - " numbers, and hyphens. " + " numbers, underscores, and hyphens. " f"ID: {submission['addonId']}" )