import pytest
from savman import gameman

@pytest.fixture
def dir1(tmpdir):
    return tmpdir.mkdir('dir1')

@pytest.fixture
def dir2(tmpdir):
    return tmpdir.mkdir('dir2')

@pytest.fixture
def customfile(tmpdir, dir1, dir2):
    file = tmpdir.join('custom.txt')
    custom = '''
---
name: My Game
directory: {}
include:
- folder1/*   # Include all files from folder
exclude:
- '*.png'
---
name: My Game 2
directory: {}
'''.format(str(dir1), str(dir2))
    file.write(custom)
    return file



def test_load_custom(customfile, dir1, dir2):
    gman = gameman.GameMan('DUMMY')
    gman.load_custom(str(customfile))
    assert 'MyGame' in gman.games
    assert 'MyGame2' in gman.games
    game1 = gman.games['MyGame']
    game2 = gman.games['MyGame2']
    assert game1.name == 'My Game'
    assert game2.name == 'My Game 2'
    assert game1.locations[0].path == str(dir1)
    assert game2.locations[0].path == str(dir2)
    assert 'folder1/*' in game1.locations[0].include
    assert '*.png' in game1.locations[0].exclude  
@@ -35,16 +35,293 @@
 ameman%0A%0A
+@pytest.fixture%0Adef gamedir(tmpdir):%0A    groot = tmpdir.mkdir('Games')%0A    gdir = groot.mkdir('MyGame')%0A    f1 = gdir.join('test1.txt')%0A    f2 = gdir.join('test2.txt')%0A    f3 = gdir.join('test3.png')%0A    f1.write('test1'); f2.write('test2'); f3.write('test3')%0A    return gdir%0A%0A
 @pytest.
@@ -338,32 +338,32 @@
 f dir1(tmpdir):%0A
-
     return tmpdi
@@ -766,17 +766,16 @@
  file%0A%0A%0A
-%0A
 def test
@@ -1243,16 +1243,16 @@
 include%0A
-
     asse
@@ -1293,8 +1293,611 @@
 xclude  
+%0A%0Adef test_find_games(tmpdir, gamedir):%0A    database = %7B%0A        'games': %7B'MyGame': %7B'name': 'My Game'%7D%7D,%0A        'locations': %7B%0A            ('MyGame', 0): %7B%0A                'type': 'profile', %0A                'profile_items': %5B'test1.txt', 'test2.txt'%5D,%0A                'profile_dir': 'MyGame',%0A                'exclude': None, 'include': None, 'subdir': None%0A                %7D%0A            %7D%0A        %7D%0A    gman = gameman.GameMan(database)%0A    gman.finder.searchpaths = %5Bstr(tmpdir)%5D%0A    gman.find_games()%0A%0A    assert 'MyGame' in gman.games%0A    assert gman.games%5B'MyGame'%5D.locations%5B0%5D.path == gamedir%0A

Add find_games test