def object_in_body_matcher(r1, r2, decrypter=None): try: if decrypter is not None: assert decrypter(r1.body.decode("utf-8")) == decrypter(r2.body.decode("utf-8")) else: assert json.loads(url_decode(r1.body.decode("utf-8"))) == json.loads(url_decode(r2.body.decode("utf-8"))) except AssertionError: return False return True
def test_set_state_single_channel(self): self.set_state.channels('ch').state(self.state) self.assertEquals(self.set_state.build_path(), SetState.SET_STATE_PATH % (pnconf.subscribe_key, "ch", self.pubnub.uuid)) params = self.set_state.build_params_callback()({}) self.assertEqual(params['pnsdk'], sdk_name) self.assertEqual(params['uuid'], self.pubnub.uuid) self.assertEqual(json.loads(helper.url_decode(params['state'])), json.loads(helper.url_decode('%7B%22count%22%3A%205%2C%20%22name%22%3A%20%22Alex%22%7D'))) self.assertEqual(self.set_state._channels, ['ch'])
def object_in_body_matcher(r1, r2, decrypter=None): try: if decrypter is not None: assert decrypter(r1.body.decode('utf-8')) == decrypter( r2.body.decode('utf-8')) else: assert json.loads(url_decode( r1.body.decode('utf-8'))) == json.loads( url_decode(r2.body.decode('utf-8'))) except AssertionError: return False return True
def object_in_path_matcher(r1, r2, decrypter=None): try: path1 = r1.path.split("/") path2 = r2.path.split("/") for k, v in enumerate(path1): if k == (len(path1) - 1): if decrypter is not None: assert decrypter(url_decode(v)) == decrypter(url_decode(path2[k])) else: assert json.loads(url_decode(v)) == json.loads(url_decode(path2[k])) else: assert v == path2[k] except AssertionError: return False return True
def object_in_path_matcher(r1, r2, decrypter=None): try: path1 = r1.path.split('/') path2 = r2.path.split('/') for k, v in enumerate(path1): if k == (len(path1) - 1): if decrypter is not None: assert decrypter(url_decode(v)) == decrypter( url_decode(path2[k])) else: assert json.loads(url_decode(v)) == json.loads( url_decode(path2[k])) else: assert v == path2[k] except AssertionError: return False return True