def test_dont_archive_when_missing_dep(write_data_to_file): """ If missing dependencies do not archive it """ arch = InsightsArchive(InsightsConfig()) cmd = MagicMock(spec=InsightsCommand) cmd.get_output.return_value = "Missing Dependencies:" cmd.archive_path = '/path/to/command' arch.add_to_archive(cmd) write_data_to_file.assert_not_called()
def test_dont_archive_when_command_not_found(write_data_to_file): """ If the command is not found do not archive it """ arch = InsightsArchive(InsightsConfig()) cmd = MagicMock(spec=InsightsCommand) cmd.get_output.return_value = 'timeout: failed to run command blah: No such file or directory' cmd.archive_path = '/path/to/command' arch.add_to_archive(cmd) write_data_to_file.assert_not_called() cmd.get_output.return_value = '/usr/bin/command -a' arch.add_to_archive(cmd) write_data_to_file.assert_called_once()