Example #1
0
 def test_wrongstatusmessagetype(self):
     with pytest.raises(TypeError):
         _ = Status(reqtime=datetime.now(),
                    statusmessage=5,
                    status="Test",
                    statustime=datetime.now(),
                    time=datetime.now())
Example #2
0
 def test_partialstatus(self):
     with pytest.raises(TypeError):
         tsstat = Status(reqtime=datetime.now())
         _ = Message(sender="TestSender",
                     type=MsgType.STATUS,
                     signal=Signal.BEAT,
                     body=tsstat)
Example #3
0
 def _interrupthook(self):
     """Sends a detailed BEAT message, indicating that this Musician has been interrupted"""
     self._answerconductor(
         Signal.BEAT, MsgType.STATUS,
         Status(reqtime=None,
                status=INTERRUPTED_STATUS,
                time=datetime.now(),
                statustime=datetime.now(),
                statusmessage="End of actors execution"))
 def test_nonestatus(self):
     out = Status(reqtime=None,
                  status=None,
                  statusmessage=None,
                  time=None,
                  statustime=None)
     assert out
     assert out.reqtime is None
     assert out.status is None
     assert out.statusmessage is None
     assert out.time is None
     assert out.statustime is None
 def test_fullstatus(self):
     nowdt = datetime.now()
     out = Status(reqtime=nowdt,
                  status="Test",
                  statusmessage="Test",
                  time=nowdt,
                  statustime=nowdt)
     assert out
     assert out.reqtime == nowdt
     assert out.status == "Test"
     assert out.statusmessage == "Test"
     assert out.time == nowdt
     assert out.statustime == nowdt
        def test_nonestatus(self):
            rick = Status(reqtime=None,
                          status=None,
                          statusmessage=None,
                          time=None,
                          statustime=None)
            picklerick = pickle.loads(pickle.dumps(rick))

            assert picklerick == rick
            assert picklerick.reqtime is None
            assert picklerick.status is None
            assert picklerick.statusmessage is None
            assert picklerick.time is None
            assert picklerick.statustime is None
        def test_fullstatus(self):
            nowdt = datetime.now()
            rick = Status(reqtime=nowdt,
                          status="Test",
                          statusmessage="Test",
                          time=nowdt,
                          statustime=nowdt)
            picklerick = pickle.loads(pickle.dumps(rick))

            assert picklerick == rick
            assert picklerick.reqtime == nowdt
            assert picklerick.status == "Test"
            assert picklerick.statusmessage == "Test"
            assert picklerick.time == nowdt
            assert picklerick.statustime == nowdt
    def test_msgtypestatus(self):
        dtnow = datetime.now()
        statusbody = Status(reqtime=dtnow,
                            status="Test",
                            time=dtnow,
                            statustime=dtnow,
                            statusmessage="Test status")
        out = Message(sender="Test",
                      type=MsgType.STATUS,
                      signal=Signal.BEAT,
                      body=statusbody)

        assert out.sender == "Test"
        assert out.type == MsgType.STATUS
        assert out.signal == Signal.BEAT
        assert out.body == statusbody
Example #9
0
 def _handlebeat(self, msg: Message) -> Union[Signal, None]:
     """extends BaseMusician._handlebeat. It adds the status states to the STATUS beat"""
     msgtype = msg.type
     if msgtype is MsgType.NONE:
         self._answerconductor(Signal.BEAT, MsgType.NONE, None)
         return Signal.BEAT
     elif msgtype is MsgType.STATUS:
         self._answerconductor(
             Signal.BEAT, MsgType.STATUS,
             Status(reqtime=None,
                    status=self._status,
                    time=datetime.now(),
                    statustime=self._statustime,
                    statusmessage=self._statusdetail))
         return Signal.BEAT
     else:
         return None
    def test_msgtypestatus(self):
        dtnow = datetime.now()
        statusbody = Status(reqtime=dtnow,
                            status="Test",
                            time=dtnow,
                            statustime=dtnow,
                            statusmessage="Test status")
        rick = Message(sender="Test",
                       type=MsgType.STATUS,
                       signal=Signal.BEAT,
                       body=statusbody)
        picklerick = pickle.loads(pickle.dumps(rick))

        assert picklerick == rick
        assert picklerick.sender == "Test"
        assert picklerick.type == MsgType.STATUS
        assert picklerick.signal == Signal.BEAT
        assert picklerick.body == statusbody