示例#1
0
    def test_client_copy_from_both_protobuf(self):
        """util.proto_copy_from works with two protobuf proto messages."""
        destination = ProtobufFixture()
        origin = ProtobufFixture()
        origin.name = "Test"

        util.proto_copy_from(destination, origin)

        self.assertEqual(destination.name, "Test")
        self.assertIsNot(destination, origin)
示例#2
0
    def test_client_copy_from_protobuf_destination(self):
        """util.proto_copy_from works with a protobuf dest and a proto_plus origin."""
        destination = ProtoPlusFixture()
        destination = type(destination).pb(destination)
        origin = ProtoPlusFixture()
        origin.name = "Test"

        util.proto_copy_from(destination, origin)

        self.assertEqual(destination.name, "Test")
        self.assertIsNot(destination, origin)
示例#3
0
    def copy_from(cls, destination, origin):
        """Copies protobuf and proto-plus messages into one-another.

        This method consolidates the CopyFrom logic of protobuf and proto-plus
        messages into a single helper method. The destination message will be
        updated with the exact state of the origin message.

        Args:
            destination: The message where changes are being copied.
            origin: The message where changes are being copied from.
        """
        return util.proto_copy_from(destination, origin)