Example #1
0
 def action(self, runner: 'Runner') -> bool:
     super().action(runner)
     # Now we have runner, we can fill in all the message fields
     message = Message(self.msgtype, **self.resolve_args(runner, self.kwargs))
     missing = message.missing_fields()
     if missing:
         raise SpecFileError(self, "Missing fields {}".format(missing))
     binmsg = io.BytesIO()
     message.write(binmsg)
     runner.recv(self, self.find_conn(runner), binmsg.getvalue())
     msg_to_stash(runner, self, message)
     return True
Example #2
0
    def get_output_message(self, conn: Conn,
                           event: ExpectMsg) -> Optional[bytes]:
        if self.config.getoption('verbose'):
            print("[GET_OUTPUT_MESSAGE {}]".format(conn))

        # We make the message they were expecting.
        msg = Message(event.msgtype, **event.resolve_args(self, event.kwargs))

        # Fake up the other fields.
        for m in msg.missing_fields():
            ftype = msg.messagetype.find_field(m.name)
            msg.set_field(m.name, self.fake_field(ftype.fieldtype))

        binmsg = io.BytesIO()
        msg.write(binmsg)
        return binmsg.getvalue()