def test(self): for data in ["", "Hello", "Hello World!\nnew\nlines"]: self.assertEqual(rpc._Compress(data), (constants.RPC_ENCODING_NONE, data)) for data in [512 * " ", 5242 * "Hello World!\n"]: compressed = rpc._Compress(data) self.assertEqual(len(compressed), 2) self.assertEqual(backend._Decompress(compressed), data)
def _VerifyRequest(req): (uldata, ) = serializer.LoadJson(req.post_data) self.assertEqual(len(uldata), 7) self.assertEqual(uldata[0], tmpfile.name) self.assertEqual(list(uldata[1]), list(rpc._Compress(data))) self.assertEqual(uldata[2], st.st_mode) self.assertEqual(uldata[3], "user%s" % os.getuid()) self.assertEqual(uldata[4], "group%s" % os.getgid()) self.assertTrue(uldata[5] is not None) self.assertEqual(uldata[6], st.st_mtime) req.success = True req.resp_status_code = http.HTTP_OK req.resp_body = serializer.DumpJson((True, None))