示例#1
0
 def __get_log_file(self):
     log_file_name = u"%s_%s.log" % (self.meta_data['case_name'],
                                     DateTimeUtils.get_stamp_date())
     log_file = os.path.join(self.case_log_path, log_file_name)
     if not os.path.isfile(log_file):
         FileSystemUtils.mkdirs(self.case_log_path)
     return log_file
示例#2
0
    def start_test(self, module_name, case_name, resp_tester, tester):
        '''
        @param module_name: test set name or test module name
        @param case_name: normal text case name, may contain '@#$~%^(+=-)&* ...'
        @param resp_tester: name of responsible tester
        @param tester: name of tester who run this case  
        '''
        self.meta_data = {
            "module_name": module_name,
            "raw_case_name": case_name,
            "case_name": FileSystemUtils.get_legal_filename(case_name),
            "status": "pass",
            "resp_tester": resp_tester,
            "tester": tester,
            "start_at": time.time(),
            "end_at": "",
        }

        FileSystemUtils.mkdirs(self.case_log_path)
        #         FileSystemUtils.mkdirs(self.screen_shot_path)

        log_file = self.__get_log_file()
        with codecs.open(log_file, "a", "utf-8") as f:
            f.write(u"\n**************  %s [%s]  ***************\n" %
                    (u"Case Log From Rock4 Test Service Framework",
                     self.meta_data['case_name']))
示例#3
0
    def test_init_test_suite_from_dir(self):
        cases_path = r'test_tmp\testcases'
        p1 = os.path.join(cases_path, "t1")
        p2 = os.path.join(cases_path, "t2")

        FileSystemUtils.mkdirs(p1)
        FileSystemUtils.mkdirs(p2)
        shutil.copyfile(self.case, os.path.join(cases_path, "t.yaml"))
        shutil.copyfile(self.case, os.path.join(p1, "t1.yaml"))
        shutil.copyfile(self.case, os.path.join(p2, "t2.yaml"))

        task_obj = init_test_suite(cases_path, Runner)

        self.assertEqual(isinstance(task_obj, TaskSuite), True)
        self.assertEqual(len(task_obj.tasks), 3)
示例#4
0
    def test_load_files_from_dir(self):
        # file path.
        cases_path = r'test_tmp\testcases'
        p1 = os.path.join(cases_path, "t1")
        p2 = os.path.join(cases_path, "t2")

        FileSystemUtils.mkdirs(p1)
        FileSystemUtils.mkdirs(p2)
        shutil.copyfile(self.case, os.path.join(cases_path, "t.yaml"))
        shutil.copyfile(self.case, os.path.join(p1, "t1.yaml"))
        shutil.copyfile(self.case, os.path.join(p2, "t2.yaml"))

        cases = YamlCaseLoader.load_files(cases_path)
        self.assertEqual(len(cases), 3)

        all_cases_file_name = [
            os.path.basename(case["file_path"]) for case in cases
        ]
示例#5
0
    def test_load_folder_files(self):

        cases_path = r'test_tmp\testcases'
        p1 = os.path.join(cases_path, "t1")
        p2 = os.path.join(cases_path, "t2")

        FileSystemUtils.mkdirs(p1)
        FileSystemUtils.mkdirs(p2)
        shutil.copyfile(self.case, os.path.join(cases_path, "t.yaml"))
        shutil.copyfile(self.case, os.path.join(p1, "t1.yaml"))
        shutil.copyfile(self.case, os.path.join(p2, "t2.yaml"))

        result1 = FileUtils.load_folder_files(p1, recursive=False)
        self.assertEqual(len(result1), 1)

        result2 = FileUtils.load_folder_files(cases_path, recursive=True)
        self.assertEqual(len(result2), 3)

        result3 = FileUtils.load_file(self.csv)
        self.assertIsInstance(result3, list)
        self.assertIsInstance(result3[0], dict)
示例#6
0
 def test_mkdirs(self):
     p = os.path.join(self.results_path, 't1', 't2', 't3')
     FileSystemUtils.mkdirs(p)
     self.assertEqual(os.path.isdir(p), True)
     shutil.rmtree(p)