def test_unavailable(self): mock_run_smartctl = self.patch(smartctl, "run_smartctl") mock_run_smartctl.return_value = ("Product: %s\n" "SMART support is: Unavailable\n" % factory.make_name("product")) mock_exit_skipped = self.patch(smartctl, "exit_skipped") smartctl.check_SMART_support(factory.make_name("blockdevice")) self.assertThat(mock_exit_skipped, MockCalledOnce())
def test__unavailable(self): mock_run_smartctl = self.patch(smartctl, 'run_smartctl') mock_run_smartctl.return_value = ('Product: %s\n' 'SMART support is: Unavailable\n' % factory.make_name('product')) mock_exit_skipped = self.patch(smartctl, 'exit_skipped') smartctl.check_SMART_support(factory.make_name('blockdevice')) self.assertThat(mock_exit_skipped, MockCalledOnce())
def test_SMART_support_is_available(self): storage = factory.make_name('storage') mock_check_output = self.patch(smartctl, "check_output") mock_check_output.return_value = SMARTCTL_OUTPUT.encode('utf-8') smartctl.check_SMART_support(storage) self.assertThat( mock_check_output, MockCalledOnceWith(['sudo', '-n', 'smartctl', '--all', storage], stderr=STDOUT, timeout=smartctl.TIMEOUT))
def test__available(self): mock_run_smartctl = self.patch(smartctl, 'run_smartctl') mock_run_smartctl.return_value = ('Product: %s\n' 'SMART support is: Available\n' % factory.make_name('product')) self.assertItemsEqual([None, []], smartctl.check_SMART_support( factory.make_name('blockdevice')))
def test__available_megaraid(self): mock_run_smartctl = self.patch(smartctl, 'run_smartctl') mock_run_smartctl.return_value = ('Product: MegaRAID\n' 'SMART support is: Unavailable\n') scsi_ids = [random.randint(0, 127) for _ in range(3)] self.patch(smartctl, 'detect_megaraid_config').return_value = scsi_ids self.assertItemsEqual(['megaraid', scsi_ids], smartctl.check_SMART_support( factory.make_name('blockdevice')))
def test_available(self): mock_run_smartctl = self.patch(smartctl, "run_smartctl") mock_run_smartctl.return_value = ("Product: %s\n" "SMART support is: Available\n" % factory.make_name("product")) self.assertItemsEqual( [None, []], smartctl.check_SMART_support(factory.make_name("blockdevice")), )
def test_available_megaraid(self): mock_run_smartctl = self.patch(smartctl, "run_smartctl") mock_run_smartctl.return_value = ("Product: MegaRAID\n" "SMART support is: Unavailable\n") scsi_ids = [random.randint(0, 127) for _ in range(3)] self.patch(smartctl, "detect_megaraid_config").return_value = scsi_ids self.assertItemsEqual( ["megaraid", scsi_ids], smartctl.check_SMART_support(factory.make_name("blockdevice")), )