예제 #1
0
 def send_to_users(cls, userids, pl_type, payload):
     """
     :param userids: list of userids to send the data to
     :param pl_type: Type of the payload as an arbitrary string
     :param payload: dictionary that will be json encoded and send to each user
     :return:
     """
     cls.connect()
     data = {"users": userids, "type": pl_type, "payload": payload}
     cls.r.publish('notifications', json_stringify(data))
예제 #2
0
 def send_to_users(cls, userids, data):
     """
     :param userids: list of userids to send the data to
     :param data: dictionary that will be json encoded and send to each user
     :return:
     """
     cls.connect()
     cls.r.publish(
         'notifications', '{{"users" : [{}], "data": {}}}'.format(
             ','.join(map(str, userids)), json_stringify(data)))
예제 #3
0
 def send_to_users(cls, userids, pl_type, payload):
     """
     :param userids: list of userids to send the data to
     :param pl_type: Type of the payload as an arbitrary string
     :param payload: dictionary that will be json encoded and send to each user
     :return:
     """
     cls.connect()
     data = {"users": userids,
             "type": pl_type,
             "payload": payload}
     cls.r.publish('notifications', json_stringify(data))
예제 #4
0
 def when_calling_endpoint(self):
     method = self.request_data['method'].lower()
     path = self.request_data['endpoint']
     data = self.request_data.get('body')
     api = getattr(self._client, method)
     try:
         self.actual_response = api(
             path=path,
             data=json_stringify(data),
             content_type='application/json',
         )
     except Exception as e:
         self.actual_exception = TracebackException.from_exception(e)
예제 #5
0
 def when_calling_endpoint(self):
     method = self.request_data['method'].lower()
     path = self.request_data['endpoint']
     data = self.request_data.get('body')
     api = getattr(self._client, method)
     try:
         self.actual_response = api(
             path=path,
             data=json_stringify(data),
             content_type='application/json',
         )
     except Exception as e:
         self.actual_exception = e
예제 #6
0
 def send_to_users(cls, userids, data):
     """
     :param userids: list of userids to send the data to
     :param data: dictionary that will be json encoded and send to each user
     :return:
     """
     cls.connect()
     cls.r.publish('notifications', '{{"users" : [{}], "data": {}}}'.format(','.join(map(str, userids)), json_stringify(data)))
예제 #7
0
 def post(self, path, data=None, **kwargs):
     return super().post(
         path=path,
         data=json_stringify(data),
         content_type='application/json; charset=utf-8',
     )
예제 #8
0
 def given_json_response(self, content):
     self.given_raw_response(json_stringify(content))
예제 #9
0
 def test_json_stringify_creates_json_from_dict(self):
     result = json_stringify({'a': 1, 'b': [2, 3], 'c': {'d': 4}})
     self.assertEqual(result, b'{"a":1,"b":[2,3],"c":{"d":4}}')
예제 #10
0
 def test_json_stringify_creates_none_from_none(self):
     result = json_stringify(None)
     self.assertEqual(result, None)
예제 #11
0
 def test_json_stringify_creates_none_from_none(self):
     result = json_stringify(None)
     self.assertEqual(result, None)
예제 #12
0
 def test_json_stringify_creates_json_from_dict(self):
     result = json_stringify({'a': 1, 'b': [2, 3], 'c': {'d': 4}})
     self.assertEqual(result, b'{"a":1,"b":[2,3],"c":{"d":4}}')