fix tests
This commit is contained in:
parent
3f37b6ff24
commit
35926037a6
@ -46,7 +46,7 @@ class Comment(object):
|
||||
for field in self.fields:
|
||||
if field == 'text' and field not in data:
|
||||
raise ValueError('Comment needs at least text, but no text was provided.')
|
||||
comment.__dict__[field] = data.get(field)
|
||||
setattr(comment, field, data.get(field))
|
||||
|
||||
return comment
|
||||
|
||||
@ -62,5 +62,5 @@ class Comment(object):
|
||||
def md5(self):
|
||||
hv = hashlib.md5()
|
||||
for key in set(self.fields) - set(['parent', ]):
|
||||
hv.update(getattr(self, key).encode('utf-8', errors="replace") or u'')
|
||||
hv.update((getattr(self, key) or u"").encode('utf-8', errors="replace"))
|
||||
return hv.hexdigest()
|
||||
|
@ -45,7 +45,6 @@ def create(app, environ, request, uri):
|
||||
try:
|
||||
comment = models.Comment.fromjson(request.data)
|
||||
except ValueError as e:
|
||||
print(1)
|
||||
return Response(unicode(e), 400)
|
||||
|
||||
for attr in 'author', 'email', 'website':
|
||||
@ -53,13 +52,11 @@ def create(app, environ, request, uri):
|
||||
try:
|
||||
setattr(comment, attr, cgi.escape(getattr(comment, attr)))
|
||||
except AttributeError:
|
||||
print(1)
|
||||
Response('', 400)
|
||||
|
||||
try:
|
||||
rv = app.db.add(uri, comment)
|
||||
except ValueError:
|
||||
print(1)
|
||||
abort(400) # FIXME: custom exception class, error descr
|
||||
|
||||
md5 = rv.md5
|
||||
|
@ -19,7 +19,7 @@ class TestComments(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
fd, self.path = tempfile.mkstemp()
|
||||
self.app = Isso(self.path, '...', '...', 15*60)
|
||||
self.app = Isso(self.path, '...', '...', 15*60, "...")
|
||||
|
||||
self.client = Client(self.app, Response)
|
||||
self.get = lambda *x, **z: self.client.get(*x, **z)
|
||||
|
Loading…
Reference in New Issue
Block a user