def testPrepareFilesStrategyZipShouldUnpackTheZipFileAssociatedWithTheDeliveryToTheGivenPath( self): strategy = PrepareFilesStrategyZip() strategy.zip = TestPrepareFilesStrategy.ZIP_FILE_PATH strategy.prepare_files(TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH) self.assertTrue( os.path.exists(TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH + TestPrepareFilesStrategy.ZIPPED_FILE_NAME))
class SetupEnviroment(): def __init__(self): self.prepare_files_strategy = PrepareFilesStrategyZip() self.log = LoggerManager().get_new_logger("setup enviroment") def run(self, automatic_correction, working_dir): self.log.debug("setting up enviroment...") self.log.debug("cleaning up working directory...") shutil.rmtree(working_dir, ignore_errors=True) self.log.debug("preparing delivery files...") self.prepare_files_strategy.zip = automatic_correction.delivery os.mkdir(working_dir) self.prepare_files_strategy.prepare_files(working_dir) shutil.copy(automatic_correction.script, working_dir + "/" + os.path.basename(automatic_correction.script)) # We must ensure the script is runnable process = subprocess.Popen(["chmod", "a+x", working_dir + "/" + os.path.basename(automatic_correction.script)]) process.wait() self.log.debug("enviroment set.")
class SetupEnviroment(): def __init__(self): self.prepare_files_strategy = PrepareFilesStrategyZip() self.log = LoggerManager().get_new_logger("setup enviroment") def run(self, automatic_correction, working_dir): self.log.debug("setting up enviroment...") self.log.debug("cleaning up working directory...") shutil.rmtree(working_dir, ignore_errors=True) self.log.debug("preparing delivery files...") self.prepare_files_strategy.zip = automatic_correction.delivery os.mkdir(working_dir) self.prepare_files_strategy.prepare_files(working_dir) shutil.copy( automatic_correction.script, working_dir + "/" + os.path.basename(automatic_correction.script)) # We must ensure the script is runnable process = subprocess.Popen([ "chmod", "a+x", working_dir + "/" + os.path.basename(automatic_correction.script) ]) process.wait() self.log.debug("enviroment set.")
def testPrepareFilesStrategyZipShouldRiseIllegalStateExceptionIfCalledWithoutSettingTheSourceFile( self): strategy = PrepareFilesStrategyZip() with self.assertRaises(IllegalStateException): strategy.prepare_files( TestPrepareFilesStrategy.UNZIP_DESTINATION_PATH)