示例#1
0
    def test_upload_dup_file_failure_case02(self, ome_default_args,
                                            ome_connection_firmware_mock,
                                            ome_response_mock):
        ome_response_mock.json_data = {
            "value": [{
                "Id": [1111, 2222, 3333],
                "DeviceServiceTag": "KLBR222",
                "dup_file": "/root/Ansible_EXE/BIOS_87V69_WN64_2.4.7.EXE"
            }]
        }
        ome_response_mock.status_code = 500

        if sys.version_info.major == 3:
            builtin_module_name = 'builtins'
        else:
            builtin_module_name = '__builtin__'
        f_module = self.get_module_mock(
            params={
                'dup_file': "/root1/Ansible_EXE/BIOS_87V69_WN64_2.4.7.EXE",
                'hostname': '192.168.0.1'
            })
        with patch("{0}.open".format(builtin_module_name),
                   mock_open(read_data="data")) as mock_file:
            with pytest.raises(Exception) as exc:
                self.module.upload_dup_file(ome_connection_firmware_mock,
                                            f_module)
        assert exc.value.args[0] == "Unable to upload {0} to {1}".format(
            '/root1/Ansible_EXE/BIOS_87V69_WN64_2.4.7.EXE', '192.168.0.1')
示例#2
0
 def test_firmware_update_success_case03(self, redfish_default_args,
                                         redfish_firmware_connection_mock,
                                         redfish_response_mock, mocker):
     mocker.patch(
         MODULE_PATH + "redfish_firmware._get_update_service_target",
         return_value=('2134', 'nhttp://dell.com', 'multipart/form-data'))
     mocker.patch(MODULE_PATH + "redfish_firmware._encode_form_data",
                  return_value=({
                      "file": (3, "nhttp://dell.com", "multipart/form-data")
                  }, "multipart/form-data"))
     redfish_default_args.update({
         "image_uri": "nhttp://home/firmware_repo/component.exe",
         "transfer_protocol": "HTTP"
     })
     f_module = self.get_module_mock(params=redfish_default_args)
     redfish_response_mock.status_code = 201
     redfish_response_mock.success = True
     redfish_response_mock.json_data = {
         "image_uri": "nhttp://home/firmware_repo/component.exe",
         "transfer_protocol": "HTTP"
     }
     if sys.version_info.major == 3:
         builtin_module_name = 'builtins'
     else:
         builtin_module_name = '__builtin__'
     with patch("{0}.open".format(builtin_module_name),
                mock_open(read_data="data")) as mock_file:
         result = self.module.firmware_update(
             redfish_firmware_connection_mock, f_module)
     assert result == redfish_response_mock
示例#3
0
 def test_upload_dup_file_success_case01(self, ome_connection_firmware_mock,
                                         ome_response_mock):
     ome_response_mock.json_data = "1577786112600"
     ome_response_mock.success = True
     ome_response_mock.status_code = 200
     f_module = self.get_module_mock(
         params={
             'dup_file': "/root1/Ansible_EXE/BIOS_87V69_WN64_2.4.7.EXE"
         })
     if sys.version_info.major == 3:
         builtin_module_name = 'builtins'
     else:
         builtin_module_name = '__builtin__'
     with patch("{0}.open".format(builtin_module_name),
                mock_open(read_data="data")) as mock_file:
         result = self.module.upload_dup_file(ome_connection_firmware_mock,
                                              f_module)
     assert result == (True, "1577786112600")