forked from beeware/briefcase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request beeware#1827 from mblahay/bug_1810
Changes for bugfix 1810. Adding a validator for the formal name input…
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The formal name of an app is now validated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name", | ||
[ | ||
# Various forms of capitalization and alphanumeric | ||
"Hello World", | ||
"helloworld", | ||
"helloWorld", | ||
"hello42world", | ||
"42helloworld", | ||
# Names that include punctuation | ||
"hello_world", | ||
"hello-world", | ||
"_helloworld", | ||
"/helloworld", | ||
"Hello / World!", | ||
# Internationalized names that can be unicode-simplified | ||
"Hallo Vögel", | ||
"Bonjour Garçon", | ||
# Internationalized names that cannot be unicode-simplified | ||
"你好 世界!", | ||
], | ||
) | ||
def test_valid_formal_name(new_command, name): | ||
"""Test that valid formal names are accepted.""" | ||
assert new_command.validate_formal_name(name) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name", | ||
[ | ||
"", # Empty | ||
" ", # Just a space | ||
"\t", # Other whitespace characters | ||
"/", # Just a slash | ||
"'", | ||
"\\", | ||
"/'\\", # Multiple invalid characters | ||
], | ||
) | ||
def test_invalid_formal_name(new_command, name, tmp_path): | ||
"""Test that invalid app names are rejected.""" | ||
(tmp_path / "existing").mkdir() | ||
|
||
with pytest.raises(ValueError): | ||
new_command.validate_formal_name(name) |