Skip to content

Commit fbcc044

Browse files
committed
added tests for valid desc
1 parent a45cc06 commit fbcc044

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

src/briefcase/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ def __init__(
404404

405405
if not is_valid_description(self.description):
406406
raise BriefcaseConfigError(
407-
f"The app description is {len(self.description)} characters long.\n\n"
408-
"Descriptions should be short.\n"
407+
"The app description is too long\n\n"
408+
f"The description is {len(self.description)} characters long.\n"
409409
"Longer descriptions should use the 'long_description' field.\n"
410410
"On some platforms, descriptions may be truncated to fit platform limitations.",
411411
)

tests/config/test_AppConfig.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,53 @@ def test_invalid_app_name(name):
221221
)
222222

223223

224+
@pytest.mark.parametrize(
225+
"description",
226+
[
227+
"A simple app",
228+
"A short valid description",
229+
"A description with spaces and punctuation!",
230+
"a mid size description with-hyphens and_underscores",
231+
"a" * 80, # Exactly 80 chars
232+
],
233+
)
234+
def test_valid_description(description):
235+
"""Test that valid descriptions are accepted."""
236+
try:
237+
AppConfig(
238+
app_name="myapp",
239+
version="1.2.3",
240+
bundle="org.beeware",
241+
description=description,
242+
sources=["src/myapp"],
243+
license={"file": "LICENSE"},
244+
)
245+
except BriefcaseConfigError:
246+
pytest.fail(f"'{description}' should be a valid description")
247+
248+
249+
@pytest.mark.parametrize(
250+
"description",
251+
[
252+
"A long app name that will go over the 80 character limit set by the validation logic",
253+
"a" * 81,
254+
],
255+
)
256+
def test_invalid_description_too_long(description):
257+
"""Test that descriptions longer than 80 characters are rejected."""
258+
with pytest.raises(
259+
BriefcaseConfigError, match=r"The app description is too long\."
260+
):
261+
AppConfig(
262+
app_name="myapp",
263+
version="1.2.3",
264+
bundle="org.beeware",
265+
description=description,
266+
sources=["src/myapp"],
267+
license={"file": "LICENSE"},
268+
)
269+
270+
224271
@pytest.mark.parametrize(
225272
"bundle",
226273
[

0 commit comments

Comments
 (0)