Skip to content

Commit ba4b75e

Browse files
authored
add support for underscores in addonIds (#45)
1 parent 79731a7 commit ba4b75e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

_tests/test_validate.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,22 @@ def test_valid(self):
224224
errors
225225
)
226226

227+
@patch('os.path.basename', return_value="valid1-Addon_id")
228+
def test_valid_withSymbols(self, mock_basename):
229+
""" Error when submission does not include correct addonId format
230+
"""
231+
self.submissionData['addonId'] = "valid1-Addon_id"
232+
self.manifest['name'] = "valid1-Addon_id"
233+
errors = list(
234+
validate.checkAddonId(self.manifest, VALID_SUBMISSION_JSON_FILE, self.submissionData)
235+
)
236+
237+
self.assertEqual(
238+
[ # expected errors
239+
],
240+
errors
241+
)
242+
227243
def test_invalidPath(self):
228244
""" Error when submission path does not include correct addon ID
229245
"""
@@ -296,7 +312,7 @@ def test_invalidAddonIdFormat_spaces(self, mock_basename):
296312
[ # expected errors
297313
"Submission data 'addonId' field does not match the expected format:"
298314
" must start and end with a letter, and contain only letters,"
299-
" numbers, and hyphens. "
315+
" numbers, underscores, and hyphens. "
300316
"ID: invalid addon id"
301317
],
302318
errors
@@ -316,7 +332,7 @@ def test_invalidAddonIdFormat_invalidStartChar(self, mock_basename):
316332
[ # expected errors
317333
"Submission data 'addonId' field does not match the expected format:"
318334
" must start and end with a letter, and contain only letters,"
319-
" numbers, and hyphens. "
335+
" numbers, underscores, and hyphens. "
320336
"ID: 1invalid-addon-id"
321337
],
322338
errors

_validate/validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ def checkAddonId(
180180
"Submission data 'addonId' field does not match 'name' field in addon manifest:"
181181
f" {expectedName} vs {submission['addonId']}"
182182
)
183-
if not re.match(r"^[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9]$", expectedName):
183+
if not re.match(r"^[A-Za-z][A-Za-z0-9\-_]*[A-Za-z0-9]$", expectedName):
184184
yield (
185185
"Submission data 'addonId' field does not match the expected format:"
186186
" must start and end with a letter, and contain only letters,"
187-
" numbers, and hyphens. "
187+
" numbers, underscores, and hyphens. "
188188
f"ID: {submission['addonId']}"
189189
)
190190

0 commit comments

Comments
 (0)