# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])
# 
# Path: ice/rom_finder.py
# class ROMFinder(object):
#   def __init__(self, filesystem, parser):
#   def rom_for_path(self, console, path):
#   def _search(self, roms_directory, console):
#   def roms_for_console(self, config, console):
#   def roms_for_consoles(self, config, consoles):


import os
import shutil
import tempfile
import unittest
from mockito import *
from ice import model
from ice import rom_finder
    console = self._dummy_console("", mock(), firstdir)
    when(self.mock_filesystem).files_in_directory(firstdir, include_subdirectories=True).thenReturn(rom_paths)

    roms = self.rom_finder.roms_for_console(self.mock_config, console)
    self.assertEquals(len(roms), 2)
    [self.assertIn(rom.path, rom_paths) for rom in roms]

  def test_roms_for_consoles_returns_collection_of_all_roms(self):
    firstdir = "RandomDir"
    rom1 = os.path.join(firstdir, "rom1")
    rom2 = os.path.join(firstdir, "rom2")

    seconddir = "RandomDir2"
    rom3 = os.path.join(seconddir, "rom3")

    rom_paths = [rom1, rom2, rom3]

    when(self.mock_filesystem).files_in_directory(firstdir, include_subdirectories=True).thenReturn([rom1, rom2])
    when(self.mock_filesystem).files_in_directory(seconddir, include_subdirectories=True).thenReturn([rom3])

    console1 = self._dummy_console("", mock(), firstdir)
    console2 = self._dummy_console("", mock(), seconddir)

    roms = self.rom_finder.roms_for_consoles(self.mock_config, [console1])
    self.assertEquals(len(roms), 2)
    for rom in roms:
      self.assertIn(rom.path, rom_paths)
      self.assertEquals(rom.console, console1)

    both_consoles = [console1, console2]

# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])
# 
# Path: ice/rom_finder.py
# class ROMFinder(object):
#   def __init__(self, filesystem, parser):
#   def rom_for_path(self, console, path):
#   def _search(self, roms_directory, console):
#   def roms_for_console(self, config, console):
#   def roms_for_consoles(self, config, consoles):


# Path: tests/rom_finder_tests.py
import os
import shutil
import tempfile
import unittest
from mockito import *
from ice import model
from ice import rom_finder

    console = self._dummy_console("", mock(), firstdir)
    when(self.mock_filesystem).files_in_directory(firstdir, include_subdirectories=True).thenReturn(rom_paths)

    roms = self.rom_finder.roms_for_console(self.mock_config, console)
    self.assertEquals(len(roms), 2)
    [self.assertIn(rom.path, rom_paths) for rom in roms]

  def test_roms_for_consoles_returns_collection_of_all_roms(self):
    firstdir = "RandomDir"
    rom1 = os.path.join(firstdir, "rom1")
    rom2 = os.path.join(firstdir, "rom2")

    seconddir = "RandomDir2"
    rom3 = os.path.join(seconddir, "rom3")

    rom_paths = [rom1, rom2, rom3]

    when(self.mock_filesystem).files_in_directory(firstdir, include_subdirectories=True).thenReturn([rom1, rom2])
    when(self.mock_filesystem).files_in_directory(seconddir, include_subdirectories=True).thenReturn([rom3])

    console1 = self._dummy_console("", mock(), firstdir)
    console2 = self._dummy_console("", mock(), seconddir)

    roms = self.rom_finder.roms_for_consoles(self.mock_config, [console1])
    self.assertEquals(len(roms), 2)
    for rom in roms:
      self.assertIn(rom.path, rom_paths)
      self.assertEquals(rom.console, console1)

    both_consoles = [console1, console2]

    roms = self.rom_finder.roms_for_consoles(self.mock_config, both_consoles)