示例#1
0
 def post(self, pk=None):
     self.set_header("Content-Type", "application/json")
     user_data = json.loads(self.request.body, encoding= "ISO-8859-1")
     try:
         validate_user(user_data)            
         user_id = self.db.users.insert(user_data)
         print('User created with id ' + str(user_id))
         self.set_status(201)
     except Exception as ex:
         message = {}
         message['message'] = str(ex)
         self.write( json_util.dumps(message) )
         self.set_status(500)
示例#2
0
 def test_too_short(self):
     self.assertEqual(validate_user("inv", 5), False)
示例#3
0
 def test_something(self):
     self.assertEqual(validate_user("valid", 3), True)
示例#4
0
 def test_invalid_chars(self):
     self.assertEqual(validate_user("invalid_user", 1), False)
 def test_valid(self):
     self.assertEqual(validate_user('validuser', 3), True)
 def test_invalid_characters(self):
     self.assertEqual(validate_user('invalid_user', 1), False)