-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added validations for all components names and added and fixed test c…
…ases for the same.
- Loading branch information
1 parent
4fe713c
commit f9467c0
Showing
4 changed files
with
443 additions
and
0 deletions.
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
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 |
---|---|---|
|
@@ -101,6 +101,49 @@ def test_add_bot_with_character_limit_exceeded(self): | |
AccountProcessor.add_bot(name=name, account=pytest.account, | ||
user="[email protected]", is_new_account=True) | ||
|
||
def test_add_bot_with_invalid_name(self): | ||
import re | ||
|
||
account = pytest.account | ||
user = "[email protected]" | ||
is_new_account = True | ||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = "test#21" | ||
AccountProcessor.add_bot(name=name, account=account, user=user, is_new_account=is_new_account) | ||
|
||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = "test@3" | ||
AccountProcessor.add_bot(name=name, account=account, user=user, is_new_account=is_new_account) | ||
|
||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = " test 5" | ||
AccountProcessor.add_bot(name=name, account=account, user=user, is_new_account=is_new_account) | ||
|
||
def test_update_bot_with_invalid_name(self): | ||
import re | ||
|
||
account = pytest.account | ||
user = "[email protected]" | ||
is_new_account = True | ||
bot = "test_bot" | ||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = "test?17" | ||
AccountProcessor.update_bot(name=name, bot=bot) | ||
|
||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = "test-7" | ||
AccountProcessor.update_bot(name=name, bot=bot) | ||
|
||
with pytest.raises(AppException, | ||
match=re.escape("Invalid name! Only letters, numbers, and underscores (_) are allowed.")): | ||
name = "<test>18" | ||
AccountProcessor.update_bot(name=name, bot=bot) | ||
|
||
def test_add_bot(self): | ||
bot_response = AccountProcessor.add_bot("test", pytest.account, "[email protected]", True) | ||
bot = Bot.objects(name="test").get().to_mongo().to_dict() | ||
|
Oops, something went wrong.