11from __future__ import unicode_literals
22
33from rimlink import *
4+ from main import clientSyncFiles
45
56import unittest
67import os
@@ -142,7 +143,7 @@ def test_different_deep(self):
142143 self .assertEqual (results ['modify' ], [r"Interior\deep\hihi.txt" ])
143144 self .assertEqual (results ['add' ], [])
144145 def test_app_data (self ):
145- TOP_LOCATION = getRimworldConfigArea ()
146+ TOP_LOCATION = AppDataStructure . getRimworldConfigArea ()
146147 INNER_LOCATION = os .path .join (TOP_LOCATION , "testing" )
147148 try :
148149 os .mkdir (INNER_LOCATION )
@@ -156,12 +157,12 @@ def test_app_data(self):
156157 file = open (add_inner , "w" )
157158 file .write ("testing" )
158159 file .close ()
159- base_structure = generateStructure (getRimworldConfigArea (), app_data = getRimworldConfigArea ())
160+ base_structure = generateStructure (AppDataStructure . getRimworldConfigArea (), app_data = AppDataStructure . getRimworldConfigArea ())
160161
161162 os .remove (add )
162163 os .remove (add_inner )
163164
164- after_structure = generateStructure (getRimworldConfigArea (), app_data = getRimworldConfigArea ())
165+ after_structure = generateStructure (AppDataStructure . getRimworldConfigArea (), app_data = AppDataStructure . getRimworldConfigArea ())
165166
166167 results = compareStructures (base_structure , after_structure )
167168
@@ -177,9 +178,22 @@ def test_app_data(self):
177178 def test_different_app_data (self ):
178179 APP_DATA_BASE = "test_files/FakeAppData1/"
179180 APP_DATA_DIFFERENT = "test_files/FakeAppData2/"
181+
182+ file_name = "different.txt"
183+ file = open (os .path .join (APP_DATA_BASE , file_name ), "w" )
184+ file .write ("good" )
185+ file .close ()
186+ file = open (os .path .join (APP_DATA_DIFFERENT , file_name ), "w" )
187+ file .write ("bad" )
188+ file .close ()
189+ AppDataStructure .getRimworldConfigArea = lambda : APP_DATA_BASE
180190 base_structure = generateStructure (APP_DATA_BASE , app_data = APP_DATA_BASE )
191+ AppDataStructure .getRimworldConfigArea = lambda : APP_DATA_DIFFERENT
181192 different_structure = generateStructure (APP_DATA_DIFFERENT , app_data = APP_DATA_DIFFERENT )
193+
182194 results = compareStructures (base_structure , different_structure )
195+ self .assertEqual (results ['modify' ][0 ].path (), 'test_files/FakeAppData2/different.txt' )
196+ clientSyncFiles (results ['delete' ], results ['add' ], results ['modify' ], testing = True )
183197
184198
185199class IsFileTest (unittest .TestCase ):
@@ -196,7 +210,7 @@ def test_is_not_file(self):
196210 self .assertFalse (FileFolder ("test_files\\ RimworldBase\\ empty" ).file )
197211
198212 def test_file_indirect (self ):
199- config_location = getRimworldConfigArea ()
213+ config_location = AppDataStructure . getRimworldConfigArea ()
200214 parent = generateStructure (config_location , app_data = config_location )
201215 self .assertFalse (parent .file )
202216 for child in parent .children :
0 commit comments