def __test_copy_logs_deprecated(self, ztestsuite, localhost_log_file, fetch_logs_flag = True): """ base test method containing common code called by public test methods for testing execution of copy of logs based on deprecated function signatures """ #first set things up #create a temp dir for logs import tempfile runtime.reset_all() #create the log file on "remote" which is actually localhost with open( localhost_log_file, 'wb') as f: f.write("This is a log") runner = TestRunner(ztestsuite=ztestsuite, should_fetch_logs=fetch_logs_flag) logs_dir = tempfile.mkdtemp() runner.set_logs_dir(logs_dir) try: runner.run() #no logs specified on default, so should not have any files if fetch_logs_flag: self.assertEqual( os.listdir(logs_dir), ['ztestsuite.unittest-' + os.path.basename(localhost_log_file)]) else: self.assertEqual( os.listdir(logs_dir),[]) except: raise finally: #cleanup shutil.rmtree( logs_dir)
def __test_copy_logs_deprecated(self, ztestsuite, localhost_log_file, fetch_logs_flag=True): """ base test method containing common code called by public test methods for testing execution of copy of logs based on deprecated function signatures """ #first set things up #create a temp dir for logs import tempfile runtime.reset_all() #create the log file on "remote" which is actually localhost with open(localhost_log_file, 'wb') as f: f.write("This is a log") runner = TestRunner(ztestsuite=ztestsuite, should_fetch_logs=fetch_logs_flag) logs_dir = tempfile.mkdtemp() runner.set_logs_dir(logs_dir) try: runner.run() #no logs specified on default, so should not have any files if fetch_logs_flag: self.assertEqual(os.listdir(logs_dir), [ 'ztestsuite.unittest-' + os.path.basename(localhost_log_file) ]) else: self.assertEqual(os.listdir(logs_dir), []) except: raise finally: #cleanup shutil.rmtree(logs_dir)
def test_zopkio_launch(self): """ Run server client test suites and compare to expected outcome on test failures/successes """ runtime.reset_all() args = Args() args.testfile = "./examples/server_client/server_client.py" succeeded, failed = self._run_zopkio(args) self.assertTrue(succeeded >= 4) self.assertTrue(failed >= 12)
def test_zopkio_launch(self): """ Run server client test suites and compare to expected outcome on test failures/successes """ runtime.reset_all() args = Args() args.testfile = "./examples/server_client/server_client.py" succeeded, failed = self._run_zopkio(args) self.assertTrue( succeeded >= 4) self.assertTrue( failed >= 16)
def test_copy_logs_empty_default(self): #first set things up runtime.reset_all() ztestsuite = SampleTestSuite() runtime.set_active_config(Config("unittestconfig",{})) runner = TestRunner(ztestsuite=ztestsuite) #create a temp dir for logs import tempfile logs_dir = tempfile.mkdtemp() runner.set_logs_dir(logs_dir) runner._copy_logs() try: #no logs specified on default, so should not have any files self.assertTrue( os.listdir(logs_dir) == []) except: raise finally: #cleanup shutil.rmtree( logs_dir)
def test_copy_logs_empty_default(self): #first set things up runtime.reset_all() ztestsuite = SampleTestSuite() runtime.set_active_config(Config("unittestconfig", {})) runner = TestRunner(ztestsuite=ztestsuite) #create a temp dir for logs import tempfile logs_dir = tempfile.mkdtemp() runner.set_logs_dir(logs_dir) runner._copy_logs() try: #no logs specified on default, so should not have any files self.assertTrue(os.listdir(logs_dir) == []) except: raise finally: #cleanup shutil.rmtree(logs_dir)