# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/hostinfo.py
# def ReadDMI(name):
# def GetChassisSerial():
# def GetMachineUUID():
# def GetRandomUUID():
# def GetIdentifier():
# def GetUdevadmInfo(device_name):
# def GetTime():
# def Which(cmd):
# 
# Path: auto_forensicate/macdisk.py
# class MacDiskError(Exception):
# class Disk(object):
# def _DictFromSubprocess(command):
# def _DictFromDiskutilInfo(deviceid):
# def _DictFromDiskutilList():
# def WholeDisks():
#   def __init__(self, deviceid):
#   def Refresh(self):
# 
# Path: auto_forensicate/recipes/base.py
# class BaseArtifact(object):
# class StringArtifact(BaseArtifact):
# class FileArtifact(BaseArtifact):
# class ProcessOutputArtifact(BaseArtifact):
# class BaseRecipe(object):
#   def __init__(self, name):
#   def _GetStream(self):
#   def CloseStream(self):
#   def OpenStream(self):
#   def size(self):
#   def readable_size(self):
#   def __init__(self, path, string_content):
#   def _GetStream(self):
#   def CloseStream(self):
#   def __init__(self, path):
#   def _GetStream(self):
#   def __init__(self, command, path, ignore_failure=False):
#   def _RunCommand(self):
#   def _GetStream(self):
#   def __init__(self, name, options=None):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/disk.py
# class DiskArtifact(base.BaseArtifact):
# class MacDiskArtifact(DiskArtifact):
# class LinuxDiskArtifact(DiskArtifact):
# class DiskRecipe(base.BaseRecipe):
#   _DD_BINARY = 'dcfldd'
#   _DD_OPTIONS = ['hash=md5,sha1', 'bs=2M', 'conv=noerror', 'hashwindow=128M']
#   def __init__(self, path, size, use_dcfldd=True):
#   def _GenerateDDCommand(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def GetDescription(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def _IsUsb(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def GetDescription(self):
#   def _GetUdevadmProperty(self, prop):
#   def ProbablyADisk(self):
#   def _IsFloppy(self):
#   def _IsUsb(self):
#   def __init__(self, name, options=None):
#   def _GetLsblkDict(self):
#   def _ListAllDisksMac(self):
#   def _ListAllDisksLinux(self):
#   def _ListDisks(self, all_devices=False, names=None):
#   def _GetListDisksArtifact(self):
#   def _GetDiskInfoArtifact(self, disk):
#   def GetArtifacts(self):


import json
import unittest
import mock
from auto_forensicate import errors
from auto_forensicate import hostinfo
from auto_forensicate import macdisk
from auto_forensicate.recipes import base
from auto_forensicate.recipes import disk
    disk_object._udevadm_metadata = {'udevadm_text_output': 'fake disk info'}
    with mock.patch(
        'auto_forensicate.recipes.disk.DiskRecipe._ListDisks'
    ) as patched_listdisk:
      patched_listdisk.return_value = [disk_object]
      with mock.patch(
          'auto_forensicate.recipes.disk.DiskRecipe._GetLsblkDict'
      ) as patched_lsblk:
        patched_lsblk.return_value = self._lsblk_dict
        recipe = disk.DiskRecipe('Disk')
        recipe._platform = 'linux'
        artifacts = recipe.GetArtifacts()
        self.assertEqual(len(artifacts), 4)

        udevadm_artifact = artifacts[1]
        self.assertIsInstance(udevadm_artifact, base.StringArtifact)
        self.assertEqual(
            udevadm_artifact._GetStream().read(), b'fake disk info')
        self.assertEqual(udevadm_artifact.remote_path, 'Disks/sdx.udevadm.txt')

        lsblk_artifact = artifacts[0]
        self.assertIsInstance(lsblk_artifact, base.StringArtifact)
        self.assertEqual(
            lsblk_artifact._GetStream().read(),
            json.dumps(self._lsblk_dict).encode('utf-8'))
        self.assertEqual(lsblk_artifact.remote_path, 'Disks/lsblk.txt')

        self.assertEqual(artifacts[2], disk_object)

        file_artifact = artifacts[3]

# Path: auto_forensicate/errors.py
# class BadConfigOption(Exception):
# class ForensicateError(Exception):
# class RecipeException(Exception):
# class RetryableError(ForensicateError):
# 
# Path: auto_forensicate/hostinfo.py
# def ReadDMI(name):
# def GetChassisSerial():
# def GetMachineUUID():
# def GetRandomUUID():
# def GetIdentifier():
# def GetUdevadmInfo(device_name):
# def GetTime():
# def Which(cmd):
# 
# Path: auto_forensicate/macdisk.py
# class MacDiskError(Exception):
# class Disk(object):
# def _DictFromSubprocess(command):
# def _DictFromDiskutilInfo(deviceid):
# def _DictFromDiskutilList():
# def WholeDisks():
#   def __init__(self, deviceid):
#   def Refresh(self):
# 
# Path: auto_forensicate/recipes/base.py
# class BaseArtifact(object):
# class StringArtifact(BaseArtifact):
# class FileArtifact(BaseArtifact):
# class ProcessOutputArtifact(BaseArtifact):
# class BaseRecipe(object):
#   def __init__(self, name):
#   def _GetStream(self):
#   def CloseStream(self):
#   def OpenStream(self):
#   def size(self):
#   def readable_size(self):
#   def __init__(self, path, string_content):
#   def _GetStream(self):
#   def CloseStream(self):
#   def __init__(self, path):
#   def _GetStream(self):
#   def __init__(self, command, path, ignore_failure=False):
#   def _RunCommand(self):
#   def _GetStream(self):
#   def __init__(self, name, options=None):
#   def __enter__(self):
#   def __exit__(self, exc_type, exc_value, traceback):
#   def GetArtifacts(self):
# 
# Path: auto_forensicate/recipes/disk.py
# class DiskArtifact(base.BaseArtifact):
# class MacDiskArtifact(DiskArtifact):
# class LinuxDiskArtifact(DiskArtifact):
# class DiskRecipe(base.BaseRecipe):
#   _DD_BINARY = 'dcfldd'
#   _DD_OPTIONS = ['hash=md5,sha1', 'bs=2M', 'conv=noerror', 'hashwindow=128M']
#   def __init__(self, path, size, use_dcfldd=True):
#   def _GenerateDDCommand(self):
#   def _GetStream(self):
#   def CloseStream(self):
#   def GetDescription(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def _IsUsb(self):
#   def ProbablyADisk(self):
#   def __init__(self, path, size, use_dcfldd=True):
#   def GetDescription(self):
#   def _GetUdevadmProperty(self, prop):
#   def ProbablyADisk(self):
#   def _IsFloppy(self):
#   def _IsUsb(self):
#   def __init__(self, name, options=None):
#   def _GetLsblkDict(self):
#   def _ListAllDisksMac(self):
#   def _ListAllDisksLinux(self):
#   def _ListDisks(self, all_devices=False, names=None):
#   def _GetListDisksArtifact(self):
#   def _GetDiskInfoArtifact(self, disk):
#   def GetArtifacts(self):


# Path: tests/disk_tests.py
import json
import unittest
import mock
from auto_forensicate import errors
from auto_forensicate import hostinfo
from auto_forensicate import macdisk
from auto_forensicate.recipes import base
from auto_forensicate.recipes import disk

    disk_object._udevadm_metadata = {'udevadm_text_output': 'fake disk info'}
    with mock.patch(
        'auto_forensicate.recipes.disk.DiskRecipe._ListDisks'
    ) as patched_listdisk:
      patched_listdisk.return_value = [disk_object]
      with mock.patch(
          'auto_forensicate.recipes.disk.DiskRecipe._GetLsblkDict'
      ) as patched_lsblk:
        patched_lsblk.return_value = self._lsblk_dict
        recipe = disk.DiskRecipe('Disk')
        recipe._platform = 'linux'
        artifacts = recipe.GetArtifacts()
        self.assertEqual(len(artifacts), 4)

        udevadm_artifact = artifacts[1]
        self.assertIsInstance(udevadm_artifact, base.StringArtifact)
        self.assertEqual(
            udevadm_artifact._GetStream().read(), b'fake disk info')
        self.assertEqual(udevadm_artifact.remote_path, 'Disks/sdx.udevadm.txt')

        lsblk_artifact = artifacts[0]
        self.assertIsInstance(lsblk_artifact, base.StringArtifact)
        self.assertEqual(
            lsblk_artifact._GetStream().read(),
            json.dumps(self._lsblk_dict).encode('utf-8'))
        self.assertEqual(lsblk_artifact.remote_path, 'Disks/lsblk.txt')

        self.assertEqual(artifacts[2], disk_object)

        file_artifact = artifacts[3]

        self.assertIsInstance(file_artifact, base.FileArtifact)