fail verify_name_characters for blank name
This commit is contained in:
parent
e03db79f79
commit
543f65fc24
2 changed files with 15 additions and 0 deletions
|
@ -8,6 +8,7 @@ NAME_ALLOWED_CHARSET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0987
|
|||
|
||||
|
||||
def verify_name_characters(name):
|
||||
assert len(name) > 0, "Empty uri"
|
||||
for c in name:
|
||||
assert c in NAME_ALLOWED_CHARSET, "Invalid character"
|
||||
return True
|
||||
|
|
|
@ -2,7 +2,21 @@ from lbrynet.metadata import Metadata
|
|||
from twisted.trial import unittest
|
||||
from jsonschema import ValidationError
|
||||
|
||||
|
||||
class MetadataTest(unittest.TestCase):
|
||||
def test_name_error_if_blank(self):
|
||||
with self.assertRaises(AssertionError):
|
||||
Metadata.verify_name_characters("")
|
||||
|
||||
def test_name_error_if_contains_bad_chrs(self):
|
||||
with self.assertRaises(AssertionError):
|
||||
Metadata.verify_name_characters("wu tang")
|
||||
with self.assertRaises(AssertionError):
|
||||
Metadata.verify_name_characters("$wutang")
|
||||
with self.assertRaises(AssertionError):
|
||||
Metadata.verify_name_characters("#wutang")
|
||||
|
||||
|
||||
def test_validation_error_if_no_metadata(self):
|
||||
metadata = {}
|
||||
with self.assertRaises(ValidationError):
|
||||
|
|
Loading…
Reference in a new issue