# 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
    rom3 = model.ROM(name = 'Game3', path = '/Path/to/game3', console = fixtures.consoles.flagged)
    shortcut3 = roms.rom_to_shortcut(rom3)
    rom4 = model.ROM(name = 'Game4', path = '/Path/to/game4', console = fixtures.consoles.flagged)
    shortcut4 = roms.rom_to_shortcut(rom4)

    self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(), [rom1, rom2, rom3, rom4], None)
    new_shortcuts = shortcuts.get_shortcuts(self.user_fixture.get_context())

    self.assertEquals(len(new_shortcuts), 5)
    self.assertIn(random_shortcut, new_shortcuts)
    self.assertIn(shortcut1, new_shortcuts)
    self.assertIn(shortcut2, new_shortcuts)
    self.assertIn(shortcut3, new_shortcuts)
    self.assertIn(shortcut4, new_shortcuts)

  def test_sync_roms_for_user_logs_when_a_rom_is_added(self):
    self._set_users_shortcuts([])

    rom = model.ROM(name = 'Game1', path = '/Path/to/game1', console = fixtures.consoles.flagged)
    shortcut = roms.rom_to_shortcut(rom)

    self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(), [rom], None)

    verify(self.mock_logger).info(any())

  def test_sync_roms_for_user_logs_once_for_each_added_rom(self):
    self._set_users_shortcuts([])

    rom1 = model.ROM(name = 'Game1', path = '/Path/to/game1', console = fixtures.consoles.flagged)
    shortcut1 = roms.rom_to_shortcut(rom1)

# 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

    rom3 = model.ROM(name = 'Game3', path = '/Path/to/game3', console = fixtures.consoles.flagged)
    shortcut3 = roms.rom_to_shortcut(rom3)
    rom4 = model.ROM(name = 'Game4', path = '/Path/to/game4', console = fixtures.consoles.flagged)
    shortcut4 = roms.rom_to_shortcut(rom4)

    self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(), [rom1, rom2, rom3, rom4], None)
    new_shortcuts = shortcuts.get_shortcuts(self.user_fixture.get_context())

    self.assertEquals(len(new_shortcuts), 5)
    self.assertIn(random_shortcut, new_shortcuts)
    self.assertIn(shortcut1, new_shortcuts)
    self.assertIn(shortcut2, new_shortcuts)
    self.assertIn(shortcut3, new_shortcuts)
    self.assertIn(shortcut4, new_shortcuts)

  def test_sync_roms_for_user_logs_when_a_rom_is_added(self):
    self._set_users_shortcuts([])

    rom = model.ROM(name = 'Game1', path = '/Path/to/game1', console = fixtures.consoles.flagged)
    shortcut = roms.rom_to_shortcut(rom)

    self.synchronizer.sync_roms_for_user(self.user_fixture.get_context(), [rom], None)

    verify(self.mock_logger).info(any())

  def test_sync_roms_for_user_logs_once_for_each_added_rom(self):
    self._set_users_shortcuts([])

    rom1 = model.ROM(name = 'Game1', path = '/Path/to/game1', console = fixtures.consoles.flagged)
    shortcut1 = roms.rom_to_shortcut(rom1)

    rom2 = model.ROM(name = 'Game2', path = '/Path/to/game2', console = fixtures.consoles.flagged)