Example #1
0
 def test_init_with_args(self):
     """
     Test that a QueryRequestPayload object can be constructed with valid
     values.
     """
     query.QueryRequestPayload(self.query_functions_a)
     query.QueryRequestPayload(self.query_functions_b)
     query.QueryRequestPayload(self.query_functions_c)
Example #2
0
    def _test_write(self, encoding, query_functions):
        stream = utils.BytearrayStream()
        payload = query.QueryRequestPayload(query_functions)
        payload.write(stream)

        length_expected = len(encoding)
        length_received = len(stream)

        msg = "encoding lengths not equal"
        msg += "; expected {0}, received {1}".format(length_expected,
                                                     length_received)
        self.assertEqual(length_expected, length_received, msg)

        msg = "encoding mismatch"
        msg += ";\nexpected:\n{0}\nreceived:\n{1}".format(encoding, stream)

        self.assertEqual(encoding, stream, msg)
Example #3
0
    def _test_read(self, stream, query_functions):
        payload = query.QueryRequestPayload()
        payload.read(stream)
        expected = len(query_functions)
        observed = len(payload.query_functions)

        msg = "query functions list decoding mismatch"
        msg += "; expected {0} results, received {1}".format(
            expected, observed)
        self.assertEqual(expected, observed, msg)

        for i in xrange(len(query_functions)):
            expected = query_functions[i]
            observed = payload.query_functions[i]

            msg = "query function decoding mismatch"
            msg += "; expected {0}, received {1}".format(expected, observed)
            self.assertEqual(expected, observed, msg)
Example #4
0
 def _build_query_batch_item(self, query_functions=None):
     operation = Operation(OperationEnum.QUERY)
     payload = query.QueryRequestPayload(query_functions)
     batch_item = messages.RequestBatchItem(
         operation=operation, request_payload=payload)
     return batch_item
Example #5
0
 def _create_query_payload(self):
     return query.QueryRequestPayload()
Example #6
0
 def test_init_with_none(self):
     """
     Test that a QueryRequestPayload object can be constructed with no
     specified value.
     """
     query.QueryRequestPayload()