def test_basic(self): testPath = pathlib.Path('Output/MkdirBlockTest/TestDir1') block = MakedirsBlock(str(testPath)) res = block.run() self.assertEqual(res, True) self.assertTrue(testPath.is_dir()) rmtree('Output')
def test_testsuitsNtestcases_simple(self): testDir = "TestFiles/Blackbox_test/testsuitsNtestcases/" outDir = testDir + "TestOutput/simple/" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen"], stdout=of, stderr=of, cwd = testDir) self.assertTrue(diff(testDir + "TestOutput/simple/mazikenout.txt", testDir + "TestExpected/simple/mazikenout.txt", ignore = ["process time: .*"]))
def test_blockinBlock(self): testDir = "TestFiles/Blackbox_test/blockinBlock/" outDir = testDir + "TestOutput" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen"], stdout=of, stderr=of, cwd = testDir) self.assertTrue(diff(testDir + "TestOutput/mazikenout.txt", testDir + "TestExpected/mazikenout.txt", ignore = ["process time: .*"]))
def test_cmdArg_ScriptName(self): testDir = "TestFiles/Blackbox_test/cmdArg_ScriptName/" outDir = testDir + "TestOutput" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen", "--scriptName", "dummyScriptName.yaml"], stdout=of, stderr=of, cwd = testDir) self.assertTrue(diff(testDir + "TestOutput/mazikenout.txt", testDir + "TestExpected/mazikenout.txt", ignore = ["process time: .*"]))
def test_workingDir(self): testPath = pathlib.Path('MkdirBlockTest/TestDir1') block = MakedirsBlock(str(testPath)) testPath = pathlib.Path("Output").joinpath(testPath) res = block.run(workingDir="Output") self.assertEqual(res, True) self.assertTrue(testPath.is_dir()) rmtree('Output')
def test_shellLinux(self): if (platform.system() == "Linux"): testDir = "TestFiles/Blackbox_test/shellLinux/" outDir = testDir + "TestOutput" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen"], stdout=of, stderr=of, cwd = testDir) self.assertTrue(diff(testDir + "TestOutput/mazikenout.txt", testDir + "TestExpected/mazikenout.txt", ignore = ["process time: .*"]))
def test_upgradeScriptData1_1_0(self): testDir = "TestFiles/Blackbox_test/upgradeScriptData1.1.0/" outDir = testDir + "TestOutput/" rmtree(outDir) os.makedirs(outDir) copy_tree(testDir+"TestInput", outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen", "--upgradeScriptFile"], stdout=of, stderr=of, cwd = outDir) self.assertTrue(diff(testDir + "TestOutput/mazikenout.txt", testDir + "TestExpected/mazikenout.txt", ignore = ["process time: .*"])) self.assertTrue(diff(testDir + "TestOutput/script.yaml", testDir + "TestExpected/script.yaml"))
def test_testsuitsNtestcases_report(self): testDir = "TestFiles/Blackbox_test/testsuitsNtestcases/" outDir = testDir + "TestOutput/report" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen", "-r", "TestOutput/report/report.xml"], stdout=of, stderr=of, cwd = testDir) with open(outDir + "/report.xml", "r") as ifile: with open(outDir + "/report_diff.xml", "w") as ofile: for line in ifile: line = re.sub(r"time=\".+?\"", "time=\"\"", line) line = re.sub(r"\\", "/", line) ofile.write(line) self.assertEqual(main.diff_files(testDir + "TestOutput/report/report_diff.xml", testDir + "TestExpected/report/report_diff.xml"), [])
def test_testsuitsNtestcases_waitNfail_parallel(self): testDir = "TestFiles/Blackbox_test/testsuitsNtestcases_waitNfail/" outDir = testDir + "TestOutput/parallel/" rmtree(outDir) os.makedirs(outDir) with open(outDir + "/mazikenout.txt", "w") as of: subprocess.run(["mazikeen", "-r", "TestOutput/parallel/report.xml", "-j", "2"], stdout=of, stderr=of, cwd = testDir) with open(outDir + "/report.xml", "r") as ifile: with open(outDir + "/report_diff.xml", "w") as ofile: for line in ifile: line = re.sub(r"time=\".+?\"", "time=\"\"", line) line = re.sub(r"\\", "/", line) ofile.write(line) self.assertEqual(main.diff_files(outDir + "/report_diff.xml", outDir + "/report_diff.xml"), []) self.assertTrue(diff(testDir + "TestOutput/parallel/mazikenout.txt", testDir + "TestExpected/parallel/mazikenout.txt", ignore = ["process time: .*"]))
def test_inputfileNoutputfile(self): rmtree("Output") printer = Printer(verbose=True) capturedOutput = io.StringIO() sys.stdout = capturedOutput cmdExe = RunBlock( '"' + sys.executable + '"' + " RunBlock_test/stdinTostdout.py", inputfile="RunBlock_test/stdinTostdout.py", outputfile="RunBlock_test/Output/inputfileNoutputfile.txt") res = cmdExe.run(workingDir="TestFiles", printer=printer) sys.stdout = sys.__stdout__ self.assertEqual(res, True) with open("TestFiles/RunBlock_test/stdinTostdout.py", "r") as fh1: with open( "TestFiles/RunBlock_test/Output/inputfileNoutputfile.txt", "r") as fh2: self.assertEqual(fh1.read(), fh2.read()) rmtree("TestFiles/RunBlock_test/Output")
def run(self, workingDir="", variables={}, printer=Printer()): printer.verbose("Rmdir:", self.dir) _dir = replaceVariables(self.dir, variables, printer) return rmtree(str(pathlib.PurePath(workingDir).joinpath(_dir)), printer)