示例#1
0
    def test_remote_access_handler_run_error(self, _):
        with patch("azurelinuxagent.ga.remoteaccess.get_osutil", return_value=MockOSUtil()):
            mock_protocol = WireProtocol("foo.bar")
            mock_protocol.get_incarnation = MagicMock(side_effect=Exception("foobar!"))

            rah = RemoteAccessHandler(mock_protocol)
            rah.run()
            print(TestRemoteAccessHandler.eventing_data)
            check_message = "foobar!"
            self.assertTrue(check_message in TestRemoteAccessHandler.eventing_data[4],
                            "expected message {0} not found in {1}"
                            .format(check_message, TestRemoteAccessHandler.eventing_data[4]))
            self.assertEqual(False, TestRemoteAccessHandler.eventing_data[2], "is_success is true")
    def test_remote_access_handler_run_error(self, _):
        mock_protocol = WireProtocol("foo.bar")
        mock_protocol.get_incarnation = MagicMock(
            side_effect=RemoteAccessError("foobar!"))

        rah = RemoteAccessHandler(mock_protocol)
        rah.os_util = MockOSUtil()
        rah.run()
        print(TestRemoteAccessHandler.eventing_data)
        check_message = "foobar!"
        self.assertTrue(
            check_message in TestRemoteAccessHandler.eventing_data[4],
            "expected message {0} not found in {1}".format(
                check_message, TestRemoteAccessHandler.eventing_data[4]))
        self.assertEqual(False, TestRemoteAccessHandler.eventing_data[2],
                         "is_success is true")