Exemple #1
0
 def save(self, hash_name, key, value):
     _key = '%s%s' % (hash_name, key)
     try:
         Redis(connection_pool=self._redis_pool).set(_key, utils.encode_obj(value))
         return value
     except Exception:
         return None
Exemple #2
0
 def post_user(self):
     self.user_id = utils.fake_name()
     path = '/users'
     body = utils.encode_obj({'id': self.user_id})
     headers = {'Content-Type': 'application/json'}
     response = self.simulate_post(path, body=body, headers=headers)
     response_user_id = utils.decode_obj(response[0])['id']
     self.assertEquals(self.user_id, response_user_id)
     self.assertEqual(self.srmock.status, falcon.HTTP_201)
Exemple #3
0
 def return_body(self, resp, body, status=None):
     resp.body = encode_obj(body)
     resp.set_header('Content-Type', 'application/json')
     resp.content_type = "application/json"
     if status:
         resp.status = status
Exemple #4
0
 def on_get(self, req, resp, *args, **kwargs):
     resp.body = encode_obj({'status': 'ok'})
     resp.status = falcon.HTTP_200
Exemple #5
0
 def post_url(self):
     url = utils.fake_url()
     path = '/users/{0}/urls'.format(self.user_id)
     body = utils.encode_obj({'url': url})
     headers = {'Content-Type': 'application/json'}
     return self.simulate_post(path, body=body, headers=headers)
Exemple #6
0
 def post_user_registered(self):
     path = '/users'
     body = utils.encode_obj({'id': self.user_id})
     headers = {'Content-Type': 'application/json'}
     response = self.simulate_post(path, body=body, headers=headers)
     self.assertEqual(self.srmock.status, falcon.HTTP_409)