# Path: ice/filesystem.py
# class RealFilesystem(object):
# class FakeFilesystem(object):
#   def create_directories(self, path):
#   def path_exists(self, path):
#   def is_directory(self, path):
#   def is_file(self, path):
#   def is_writable(self, path):
#   def _paths_in_directory(self, directory, incl_subdirs=False):
#   def files_in_directory(self, directory, include_subdirectories=False):
#   def subdirectories_of_directory(self, directory, recursive=False):
#   def __init__(self, root):
#   def adjusted_path(self, path):
#   def create_directories(self, path):
#   def path_exists(self, path):
#   def is_directory(self, path):
#   def is_file(self, path):
#   def is_writable(self, path):
#   def files_in_directory(self, directory, include_subdirectories=False):
#   def subdirectories_of_directory(self, directory, recursive=False):
# 
# Path: ice/persistence/adapters/emulator_adapter.py
# class EmulatorBackedObjectAdapter(object):
#   def __init__(self, filesystem):
#   def new(self, backing_store, identifier):
#   def verify(self, emulator):
#   def save_in_store(self, backing_store, identifier, emulator):
# 
# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])


import os
import tempfile
import unittest
from mockito import *
from nose_parameterized import parameterized
from ice import filesystem
from ice.persistence.adapters import emulator_adapter
from ice import model




class EmulatorAdapterTests(unittest.TestCase):

  def setUp(self):
    fs = filesystem.RealFilesystem()
    self.adapter = emulator_adapter.EmulatorBackedObjectAdapter(fs)

  def test_verify_returns_false_when_location_is_none(self):
    emu = model.Emulator("Mednafen", None, "%l %r")
    self.assertFalse(self.adapter.verify(emu))

  def test_verify_returns_false_when_location_is_empty_string(self):
    emu = model.Emulator("Mednafen", "", "%l %r")
    self.assertFalse(self.adapter.verify(emu))

  def test_verify_returns_true_when_location_doesnt_exist(self):
    emu = model.Emulator("Mednafen", "/some/random/path/that/doesnt/exist", "%l %r")
    self.assertTrue(self.adapter.verify(emu))

  def test_verify_returns_true_when_location_is_directory(self):
    d = tempfile.mkdtemp()

# Path: ice/filesystem.py
# class RealFilesystem(object):
# class FakeFilesystem(object):
#   def create_directories(self, path):
#   def path_exists(self, path):
#   def is_directory(self, path):
#   def is_file(self, path):
#   def is_writable(self, path):
#   def _paths_in_directory(self, directory, incl_subdirs=False):
#   def files_in_directory(self, directory, include_subdirectories=False):
#   def subdirectories_of_directory(self, directory, recursive=False):
#   def __init__(self, root):
#   def adjusted_path(self, path):
#   def create_directories(self, path):
#   def path_exists(self, path):
#   def is_directory(self, path):
#   def is_file(self, path):
#   def is_writable(self, path):
#   def files_in_directory(self, directory, include_subdirectories=False):
#   def subdirectories_of_directory(self, directory, recursive=False):
# 
# Path: ice/persistence/adapters/emulator_adapter.py
# class EmulatorBackedObjectAdapter(object):
#   def __init__(self, filesystem):
#   def new(self, backing_store, identifier):
#   def verify(self, emulator):
#   def save_in_store(self, backing_store, identifier, emulator):
# 
# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])


# Path: tests/emulator_adapter_test.py
import os
import tempfile
import unittest
from mockito import *
from nose_parameterized import parameterized
from ice import filesystem
from ice.persistence.adapters import emulator_adapter
from ice import model





class EmulatorAdapterTests(unittest.TestCase):

  def setUp(self):
    fs = filesystem.RealFilesystem()
    self.adapter = emulator_adapter.EmulatorBackedObjectAdapter(fs)

  def test_verify_returns_false_when_location_is_none(self):
    emu = model.Emulator("Mednafen", None, "%l %r")
    self.assertFalse(self.adapter.verify(emu))

  def test_verify_returns_false_when_location_is_empty_string(self):
    emu = model.Emulator("Mednafen", "", "%l %r")
    self.assertFalse(self.adapter.verify(emu))

  def test_verify_returns_true_when_location_doesnt_exist(self):
    emu = model.Emulator("Mednafen", "/some/random/path/that/doesnt/exist", "%l %r")
    self.assertTrue(self.adapter.verify(emu))

  def test_verify_returns_true_when_location_is_directory(self):
    d = tempfile.mkdtemp()

    emu = model.Emulator("Mednafen", d, "%l %r")