Example #1
0
 def _build_hello(self, ready):
     pb_message = pb_controller.Hello()
     name = "JAMBON"
     pb_message.name = name
     pb_message.ready = ready
     payload = pb_message.SerializeToString()
     return self._routing_id + ' Hello ' + payload
Example #2
0
    def test_1():
        """Simple test with default value."""
        name = "Test"
        yaml_content = """
message: !CaptureHello
    message:
        name: {name}
""".format(name=name)
        data = yaml.load(yaml_content, Loader=yaml.FullLoader)
        hello = data["message"]
        assert_equal(hello.name, name)
        payload = hello.protobuf_message.SerializeToString()
        message2 = pb_controller.Hello()
        message2.ParseFromString(payload)
        assert_equal(name, message2.name)
        assert_equal(True, message2.ready)
Example #3
0
    def test_2(self):
        """Simple test with default value overriden."""
        name = "Test"
        ready = False
        yaml_content = """
message: !CaptureHello
    message:
        name: {name}
        ready: {ready}
""".format(name=name, ready=ready)
        data = yaml.load(yaml_content)
        hello = data["message"]
        assert_equal(hello.name, name)
        payload = hello.protobuf_message.SerializeToString()
        message2 = pb_controller.Hello()
        message2.ParseFromString(payload)
        assert_equal(name, message2.name)
        assert_equal(ready, message2.ready)
Example #4
0
 def test_3(self):
     """Play with the underlying library (not really a test)."""
     message = pb_controller.Hello()
     name = "JAMBON"
     message.name = name
     dico = pb2dict(message)
     message = pb_controller.Input()
     left = 0.2
     right = -0.5
     weapon1 = False
     weapon2 = True
     message.move.left = left
     message.move.right = right
     message.fire.weapon1 = weapon1
     message.fire.weapon2 = weapon2
     dico = pb2dict(message)
     message2 = dict2pb(pb_controller.Input, dico)
     assert_equal(left, message2.move.left)
     assert_equal(right, message2.move.right)
     assert_equal(weapon1, message2.fire.weapon1)
     assert_equal(weapon2, message2.fire.weapon2)