# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])
# 
# Path: ice/steam_shortcut_synchronizer.py
# class SteamShortcutSynchronizer(object):
#   def __init__(self, config, managed_rom_archive):
#   def _guess_whether_shortcut_is_managed_by_ice(self, shortcut, consoles):
#     def shortcut_is_managed_by_console(console):
#   def shortcut_is_managed_by_ice(self, managed_ids, shortcut, consoles):
#   def unmanaged_shortcuts(self, managed_ids, shortcuts, consoles):
#   def removed_shortcuts(self, current_shortcuts, new_shortcuts):
#   def added_shortcuts(self, current_shortcuts, new_shortcuts):
#   def sync_roms_for_user(self, user, users_roms, consoles, dry_run=False):
# 
# Path: ice/roms.py
# ICE_FLAG_TAG = "~ManagedByIce"
# def roms_directory(config):
# def rom_shortcut_name(rom):
# def rom_to_shortcut(rom):


import unittest
from mockito import *
from pysteam import model as steam_model
from pysteam import shortcuts
from ice import model
from ice import steam_shortcut_synchronizer
from ice import roms
from testinfra import fixtures
  def test_unmanaged_shortcuts_returns_all_shortcuts_when_given_no_history(self):
    dummy_console = self._create_dummy_console("/Some/Other/Path")
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts(None ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_filters_suspicious_shortcuts_when_given_no_history(self):
    dummy_console = self._create_dummy_console("/Some/Path")
    random_shortcut = steam_model.Shortcut("Iron Man", "/Some/Emulator/Path/emulator /Some/Path/Iron Man", "/Some/Emulator/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts(None ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [])

  def test_unmanaged_shortcuts_doesnt_filter_suspicious_shortcuts_when_we_have_history(self):
    dummy_console = self._create_dummy_console("/Some/Path")
    random_shortcut = steam_model.Shortcut("Iron Man", "/Some/Emulator/Path/emulator /Some/Path/Iron Man", "/Some/Emulator/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts([] ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_returns_shortcut_not_affiliated_with_ice(self):
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])
    unmanaged = self.synchronizer.unmanaged_shortcuts([],[random_shortcut], None)
    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_doesnt_return_shortcut_with_flag_tag(self):

# Path: ice/model.py
# ROM = collections.namedtuple('ROM', [
#   'name',
#   'path',
#   'console',
# ])
# 
# Path: ice/steam_shortcut_synchronizer.py
# class SteamShortcutSynchronizer(object):
#   def __init__(self, config, managed_rom_archive):
#   def _guess_whether_shortcut_is_managed_by_ice(self, shortcut, consoles):
#     def shortcut_is_managed_by_console(console):
#   def shortcut_is_managed_by_ice(self, managed_ids, shortcut, consoles):
#   def unmanaged_shortcuts(self, managed_ids, shortcuts, consoles):
#   def removed_shortcuts(self, current_shortcuts, new_shortcuts):
#   def added_shortcuts(self, current_shortcuts, new_shortcuts):
#   def sync_roms_for_user(self, user, users_roms, consoles, dry_run=False):
# 
# Path: ice/roms.py
# ICE_FLAG_TAG = "~ManagedByIce"
# def roms_directory(config):
# def rom_shortcut_name(rom):
# def rom_to_shortcut(rom):


# Path: tests/steam_shortcut_synchronizer_tests.py
import unittest
from mockito import *
from pysteam import model as steam_model
from pysteam import shortcuts
from ice import model
from ice import steam_shortcut_synchronizer
from ice import roms
from testinfra import fixtures

  def test_unmanaged_shortcuts_returns_all_shortcuts_when_given_no_history(self):
    dummy_console = self._create_dummy_console("/Some/Other/Path")
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts(None ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_filters_suspicious_shortcuts_when_given_no_history(self):
    dummy_console = self._create_dummy_console("/Some/Path")
    random_shortcut = steam_model.Shortcut("Iron Man", "/Some/Emulator/Path/emulator /Some/Path/Iron Man", "/Some/Emulator/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts(None ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [])

  def test_unmanaged_shortcuts_doesnt_filter_suspicious_shortcuts_when_we_have_history(self):
    dummy_console = self._create_dummy_console("/Some/Path")
    random_shortcut = steam_model.Shortcut("Iron Man", "/Some/Emulator/Path/emulator /Some/Path/Iron Man", "/Some/Emulator/Path", "", [])

    unmanaged = self.synchronizer.unmanaged_shortcuts([] ,[random_shortcut], [dummy_console])

    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_returns_shortcut_not_affiliated_with_ice(self):
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])
    unmanaged = self.synchronizer.unmanaged_shortcuts([],[random_shortcut], None)
    self.assertEquals(unmanaged, [random_shortcut])

  def test_unmanaged_shortcuts_doesnt_return_shortcut_with_flag_tag(self):

    tagged_shortcut = steam_model.Shortcut("Game", "/Path/to/game", "/Path/to", "", [roms.ICE_FLAG_TAG])