Ejemplo n.º 1
0
    def test_no_controllers(self):
        mock_run_storcli = self.patch(smartctl, "run_storcli")
        mock_run_storcli.return_value = ""
        mock_exit_skipped = self.patch(smartctl, "exit_skipped")

        smartctl.find_matching_megaraid_controller(
            factory.make_name("blockdevice"))

        self.assertThat(mock_exit_skipped, MockCalledOnce())
Ejemplo n.º 2
0
 def test_no_matching_scsi_id(self):
     mock_run_storcli = self.patch(smartctl, "run_storcli")
     mock_run_storcli.side_effect = (
         "Number of Controllers = 1",
         "Virtual Drives = 1",
         "SCSI NAA Id = %s" % factory.make_name("scsi_id"),
     )
     mock_exit_skipped = self.patch(smartctl, "exit_skipped")
     smartctl.find_matching_megaraid_controller(
         factory.make_name("blockdevice"))
     self.assertThat(mock_exit_skipped, MockCalledOnce())
Ejemplo n.º 3
0
 def test_found(self):
     scsi_id = factory.make_name()
     mock_run_storcli = self.patch(smartctl, "run_storcli")
     mock_run_storcli.side_effect = (
         "Number of Controllers = 2",
         "Virtual Drives = 1",
         "SCSI NAA Id = %s" % factory.make_name("scsi_id"),
         "Virtual Drives = 1",
         "SCSI NAA Id = %s" % scsi_id,
     )
     self.patch(smartctl.glob,
                "glob").return_value = [factory.make_name("path")]
     self.patch(smartctl.os.path, "realpath").side_effect = (
         scsi_id,
         scsi_id,
     )
     self.assertEquals(
         1,
         smartctl.find_matching_megaraid_controller(
             factory.make_name("blockdevice")),
     )