def test_fieldnames_missing_id(self): csv_content = str('Title,Test Case I D,Caseimportance,,,') input_file = StringIO(csv_content) reader = csvtools._get_csv_reader(input_file) fieldnames = csvtools._get_csv_fieldnames(reader) input_file.close() assert fieldnames is None
def test_fieldnames_trailing(self): csv_content = str('ID,Title,Test Case I D,Caseimportance,,,') input_file = StringIO(csv_content) reader = csvtools._get_csv_reader(input_file) fieldnames = csvtools._get_csv_fieldnames(reader) input_file.close() assert fieldnames == ['id', 'title', 'testcaseid', 'caseimportance']
def test_testrun_id_far(self): csv_content = str(""" ,ID,Title,Test Case I D,,,, ,(TEST_RECORDS:(""RHCF3/5_8_0_17"", @null)),,,,,""") input_file = StringIO(csv_content) reader = csvtools._get_csv_reader(input_file) testrun_id = csvtools._get_testrun_from_csv(input_file, reader) assert not testrun_id
def test_testrun_id_line(self): csv_content = str( 'Query,"(assignee.id:$[user.id] AND NOT status:inactive AND ' '(TEST_RECORDS:(""RHCF3/5_8_0_17"", @null))) ' 'AND project.id:RHCF3",,,,,,,') input_file = StringIO(csv_content) reader = csvtools._get_csv_reader(input_file) testrun_id = csvtools._get_testrun_from_csv(input_file, reader) assert testrun_id == '5_8_0_17'
def test_fieldnames_unanotated(self): csv_content = str(',,ID,Title,Test Case I D,Caseimportance') input_file = StringIO(csv_content) reader = csvtools._get_csv_reader(input_file) fieldnames = csvtools._get_csv_fieldnames(reader) input_file.close() assert fieldnames == [ 'field1', 'field2', 'id', 'title', 'testcaseid', 'caseimportance' ]
def test_testrun_id_exported(self): csv_file = os.path.join(conf.DATA_PATH, 'workitems_ids.csv') open_args = [] open_kwargs = {} try: # pylint: disable=pointless-statement unicode open_args.append('rb') except NameError: open_kwargs['encoding'] = 'utf-8' with open(csv_file, *open_args, **open_kwargs) as input_file: reader = csvtools._get_csv_reader(input_file) testrun_id = csvtools._get_testrun_from_csv(input_file, reader) assert testrun_id == '5_8_0_17'
def test_fieldnames_exported(self): csv_file = os.path.join(conf.DATA_PATH, 'workitems_ids.csv') open_args = [] open_kwargs = {} try: # pylint: disable=pointless-statement unicode open_args.append('rb') except NameError: open_kwargs['encoding'] = 'utf-8' with open(csv_file, *open_args, **open_kwargs) as input_file: reader = csvtools._get_csv_reader(input_file) fieldnames = csvtools._get_csv_fieldnames(reader) assert fieldnames == [ 'id', 'title', 'testcaseid', 'caseimportance', 'verdict', 'comment', 'stdout', 'stderr', 'exported', 'time' ]