Move copy_files_to_file_system to base_test

This commit is contained in:
mike cullerton 2022-02-07 13:43:20 -05:00
parent e24a81b924
commit 5c3ab9a035
2 changed files with 7 additions and 6 deletions

View File

@ -105,6 +105,11 @@ class BaseTest(unittest.TestCase):
self.auths = {} self.auths = {}
self.clear_test_sync_files() self.clear_test_sync_files()
@staticmethod
def copy_files_to_file_system(import_spec_path, spec_path):
"""Some tests rely on a well populated file system """
shutil.copytree(import_spec_path, spec_path)
@staticmethod @staticmethod
def clear_test_sync_files(): def clear_test_sync_files():
sync_file_root = SpecFileService().root_path() sync_file_root = SpecFileService().root_path()

View File

@ -17,10 +17,6 @@ class TestWorkflowSync(BaseTest):
import_spec_path = os.path.join(app.root_path, '..', 'tests', 'data', 'IMPORT_TEST') import_spec_path = os.path.join(app.root_path, '..', 'tests', 'data', 'IMPORT_TEST')
service = WorkflowSpecService() service = WorkflowSpecService()
def copy_files_to_file_system(self):
"""Some tests rely on a well populated file system """
shutil.copytree(self.import_spec_path, self.spec_path)
def build_file_system_from_models(self): def build_file_system_from_models(self):
"""Some tests check to see what happens when we write data to an empty file system.""" """Some tests check to see what happens when we write data to an empty file system."""
@ -39,7 +35,7 @@ class TestWorkflowSync(BaseTest):
self.service.scan_file_system() self.service.scan_file_system()
self.assertEquals(0, len(self.service.get_categories())) self.assertEquals(0, len(self.service.get_categories()))
self.assertEquals(0, len(self.service.get_specs())) self.assertEquals(0, len(self.service.get_specs()))
self.copy_files_to_file_system() self.copy_files_to_file_system(self.import_spec_path, self.spec_path)
self.service.scan_file_system() self.service.scan_file_system()
self.assertEquals(2, len(self.service.get_categories())) self.assertEquals(2, len(self.service.get_categories()))
self.assertEquals(5, len(self.service.get_specs())) self.assertEquals(5, len(self.service.get_specs()))
@ -50,7 +46,7 @@ class TestWorkflowSync(BaseTest):
self.assertEquals(1, len(self.service.master_spec.libraries)) self.assertEquals(1, len(self.service.master_spec.libraries))
def test_delete_category_and_workflows(self): def test_delete_category_and_workflows(self):
self.copy_files_to_file_system() self.copy_files_to_file_system(self.import_spec_path, self.spec_path)
self.service.scan_file_system() self.service.scan_file_system()
cat_path = SpecFileService().category_path('Category Number One') cat_path = SpecFileService().category_path('Category Number One')
shutil.rmtree(cat_path) # Remove the path, as if from a git pull and the path was removed. shutil.rmtree(cat_path) # Remove the path, as if from a git pull and the path was removed.