# 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
    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])
    unmanaged = self.synchronizer.unmanaged_shortcuts([],[tagged_shortcut], None)
    self.assertEquals(unmanaged, [])

  def test_unmanaged_shortcuts_doesnt_return_shortcut_with_appid_in_managed_ids(self):
    managed_shortcut = steam_model.Shortcut("Game", "/Path/to/game", "/Path/to", "", [])
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])
    managed_ids = [shortcuts.shortcut_app_id(managed_shortcut)]
    all_shortcuts = [managed_shortcut, random_shortcut]
    unmanaged = self.synchronizer.unmanaged_shortcuts(managed_ids, all_shortcuts, None)
    self.assertEquals(unmanaged, [random_shortcut])

  def test_added_shortcuts_doesnt_return_shortcuts_that_still_exist(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])
    shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to", "", [roms.ICE_FLAG_TAG])
    old = [shortcut1, shortcut2]
    new = [shortcut1, shortcut2]
    self.assertEquals(self.synchronizer.added_shortcuts(old, new), [])

  def test_added_shortcuts_returns_shortcuts_that_didnt_exist_previously(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])
    shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to", "", [roms.ICE_FLAG_TAG])
    new = [shortcut1, shortcut2]
    self.assertEquals(self.synchronizer.added_shortcuts([], new), [shortcut1, shortcut2])

  def test_added_shortcuts_only_returns_shortcuts_that_exist_now_but_not_before(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])

# 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

    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])
    unmanaged = self.synchronizer.unmanaged_shortcuts([],[tagged_shortcut], None)
    self.assertEquals(unmanaged, [])

  def test_unmanaged_shortcuts_doesnt_return_shortcut_with_appid_in_managed_ids(self):
    managed_shortcut = steam_model.Shortcut("Game", "/Path/to/game", "/Path/to", "", [])
    random_shortcut = steam_model.Shortcut("Plex", "/Some/Random/Path/plex", "/Some/Random/Path", "", [])
    managed_ids = [shortcuts.shortcut_app_id(managed_shortcut)]
    all_shortcuts = [managed_shortcut, random_shortcut]
    unmanaged = self.synchronizer.unmanaged_shortcuts(managed_ids, all_shortcuts, None)
    self.assertEquals(unmanaged, [random_shortcut])

  def test_added_shortcuts_doesnt_return_shortcuts_that_still_exist(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])
    shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to", "", [roms.ICE_FLAG_TAG])
    old = [shortcut1, shortcut2]
    new = [shortcut1, shortcut2]
    self.assertEquals(self.synchronizer.added_shortcuts(old, new), [])

  def test_added_shortcuts_returns_shortcuts_that_didnt_exist_previously(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])
    shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to", "", [roms.ICE_FLAG_TAG])
    new = [shortcut1, shortcut2]
    self.assertEquals(self.synchronizer.added_shortcuts([], new), [shortcut1, shortcut2])

  def test_added_shortcuts_only_returns_shortcuts_that_exist_now_but_not_before(self):
    shortcut1 = steam_model.Shortcut("Game1", "/Path/to/game1", "/Path/to", "", [roms.ICE_FLAG_TAG])

    shortcut2 = steam_model.Shortcut("Game2", "/Path/to/game2", "/Path/to", "", [roms.ICE_FLAG_TAG])