Exemple #1
0
 def test_run_should_log_result(self, monkeypatch):
     monkeypatch.setattr(commands, "log", fakelib.FakeLogger())
     monkeypatch.setattr(cmdutils, "command_log_line", mock.MagicMock())
     monkeypatch.setattr(cmdutils, "retcode_log_line", mock.MagicMock())
     cmdutils.command_log_line.return_value = "log line"
     cmdutils.retcode_log_line.return_value = "error line"
     args = ["exit 1"]
     try:
         commands.run(args)
     except cmdutils.Error:
         pass
     assert (logging.DEBUG, "log line", {}) in commands.log.messages
     assert (logging.DEBUG, "error line", {}) in commands.log.messages
Exemple #2
0
    def test_process_request(self):
        PAYLOAD = (
            b'1xtnd\xe1_\xfeeT\x8a\x18\xb3\xe0JT\xe5^\xc8\xdb\x8a_Z%'
            b'\xd8\xfcs.\xa4\xc3C\xbb>\xc6\xf1r\xd7'
            b'000000000000109200000000000')
        MSG_ID = 7
        pool = mock.MagicMock()
        pool.spUUID = SPUUID

        ret = sm.SPM_Extend_Message.processRequest(
            pool=pool, msgID=MSG_ID, payload=PAYLOAD)

        assert ret == {'status': {'code': 0, 'message': 'Done'}}
        pool.extendVolume.assert_called_with(
            self.VOL_DATA['domainID'], self.VOL_DATA['volumeID'], 4242)

        called_name, called_args, called_kwargs = pool.mock_calls[1]
        assert called_name == 'spmMailer.sendReply'
        called_msgid, called_msg = called_args
        assert called_msgid == MSG_ID
        assert called_msg.payload == (
            b'1xtnd\xe1_\xfeeT\x8a\x18\xb3\xe0JT\xe5^\xc8\xdb\x8a_Z%'
            b'\xd8\xfcs.\xa4\xc3C\xbb>\xc6\xf1r\xd700000000000010920'
            b'0000000000')
        assert called_msg.callback is None
Exemple #3
0
 def test_start_should_log_args(self, monkeypatch):
     monkeypatch.setattr(cmdutils, "command_log_line", mock.MagicMock())
     monkeypatch.setattr(commands, "log", fakelib.FakeLogger())
     cmdutils.command_log_line.return_value = "zorro"
     args = ["true"]
     commands.start(args)
     assert (logging.DEBUG, "zorro", {}) in commands.log.messages