def test_variable_is_known_when_defining_it(self): self.test.execute(ChangeCellValue(0, 0, '${var}=')) self.test.execute(ChangeCellValue(0, 1, 'Set Variable')) self.test.execute(ChangeCellValue(0, 2, '${var}')) self._verify_cell_info(0, 0, ContentType.VARIABLE, CellType.ASSIGN) self._verify_cell_info(0, 2, ContentType.UNKNOWN_VARIABLE, CellType.OPTIONAL)
def test_celltype_is_unknown_if_dict_var_given(self): self.test.execute(ChangeCellValue(0, 0, self.keyword1.name)) self.test.execute(ChangeCellValue(0, 1, '&{vars}')) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.UNKNOWN_VARIABLE, CellType.UNKNOWN) self._verify_cell_info(0, 2, ContentType.EMPTY, CellType.UNKNOWN) self._verify_cell_info(0, 3, ContentType.EMPTY, CellType.UNKNOWN)
def test_new_for_loop_with_existing_comment(self): test = self.chief.datafiles[1].tests[16] test.execute(ChangeCellValue(0, 2, '# comment')) test.execute(ChangeCellValue(0, 0, ':FOR')) self.assertEqual(test.steps[0].as_list(), [':FOR', '', '# comment']) test.execute(DeleteCell(0, 0)) self.assertEqual(test.steps[0].as_list(), ['', '# comment'])
def test_variable_setting(self): self.test.execute(ChangeCellValue(0, 0, '${my cool var}=')) self._verify_cell_info(0, 0, ContentType.VARIABLE, CellType.ASSIGN) self.test.execute(ChangeCellValue(0, 1, 'Set Variable')) self._verify_cell_info(0, 1, ContentType.LIBRARY_KEYWORD, CellType.KEYWORD) self._verify_string_change(0, 2, CellType.OPTIONAL)
def test_comment(self): self.test.execute(ChangeCellValue(0, 0, self.keyword1.name)) self.test.execute(ChangeCellValue(0, 1, '# I have something to say')) self.test.execute(ChangeCellValue(0, 2, 'to you my friend')) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.COMMENTED, CellType.MANDATORY) self._verify_cell_info(0, 2, ContentType.COMMENTED, CellType.OPTIONAL)
def test_adding_comment(self): test = self.chief.datafiles[1].tests[14] test.execute(ChangeCellValue(1, 2, '# comment')) self.assertEqual(test.steps[1].as_list(), ['', 'No Operation', '# comment']) test.execute(ChangeCellValue(1, 2, '##comment')) self.assertEqual(test.steps[1].as_list(), ['', 'No Operation', '##comment'])
def test_new_for_loop(self): test = self.project.datafiles[1].tests[10] test.execute(ChangeCellValue(0, 0, ': FOR')) test.execute(ChangeCellValue(0, 1, '${i}')) test.execute(ChangeCellValue(0, 2, 'IN RANGE')) test.execute(ChangeCellValue(0, 3, '100')) self.assertEqual(test.steps[0].as_list(), [':FOR', '${i}', 'IN RANGE', '100']) self.assertEqual(type(test.steps[0]), ForLoopStepController)
def test_comment_keyword(self): self.test.execute(ChangeCellValue(0, 0, 'I have nothing to say')) self.test.execute(ChangeCellValue(0, 1, 'to the void of darkness')) self.test.step(0).comment() self._verify_cell_info(0, 0, ContentType.LIBRARY_KEYWORD, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.COMMENTED, CellType.OPTIONAL) self._verify_cell_info(0, 2, ContentType.COMMENTED, CellType.OPTIONAL) self._verify_cell_info(0, 3, ContentType.COMMENTED, CellType.OPTIONAL)
def setUp(self): self.res_path = datafilereader.SIMPLE_TEST_SUITE_PATH self.res_name = 'new_resource_for_test_creating_and_importing_resource.txt' self.res_full_name = os.path.join(self.res_path, self.res_name) self.new_keyword_name = 'My Keywordian' self.ctrl = datafilereader.construct_chief_controller(datafilereader.SIMPLE_TEST_SUITE_PATH) self.suite = datafilereader.get_ctrl_by_name('TestSuite1', self.ctrl.datafiles) self.test = self.suite.tests[0] self.test.execute(ChangeCellValue(0,0,self.new_keyword_name)) self.test.execute(ChangeCellValue(0,1,'value'))
def test_keyword_with_varargs(self): self.test.execute(ChangeCellValue(0, 0, self.keyword2.name)) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_string_change(0, 1, CellType.OPTIONAL) self._verify_string_change(0, 2, CellType.OPTIONAL) self._verify_string_change(0, 3, CellType.OPTIONAL)
def test_keyword_with_optional_and_list_arguments(self): self.test.execute(ChangeCellValue(0, 0, self.keyword4.name)) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_string_change(0, 1, CellType.OPTIONAL) self._verify_string_change(0, 2, CellType.OPTIONAL) self._verify_string_change(0, 3, CellType.OPTIONAL) self._verify_string_change(0, 4, CellType.OPTIONAL)
def test_keyword_with_mandatory_and_optional_arguments(self): self.test.execute(ChangeCellValue(0, 0, self.keyword1.name)) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_string_change(0, 1, CellType.MANDATORY) self._verify_string_change(0, 2, CellType.OPTIONAL) self._verify_string_change(0, 3, CellType.MUST_BE_EMPTY)
def test_known_extended_variable_syntax(self): self.test.execute(ChangeCellValue(0, 0, '${var}=')) self.test.execute(ChangeCellValue(0, 1, 'Set Variable')) self.test.execute(ChangeCellValue(0, 2, 'something')) self.test.execute(ChangeCellValue(1, 0, 'log')) self.test.execute(ChangeCellValue(1, 2, '${var.lower()}')) self.test.execute(ChangeCellValue(2, 0, 'log')) self.test.execute(ChangeCellValue(2, 2, '${var+"moi"}')) self.test.execute(ChangeCellValue(3, 0, 'log')) self.test.execute(ChangeCellValue(3, 2, '${var[1:]}')) self._verify_cell_info(1, 2, ContentType.VARIABLE, CellType.OPTIONAL) self._verify_cell_info(2, 2, ContentType.VARIABLE, CellType.OPTIONAL) self._verify_cell_info(3, 2, ContentType.VARIABLE, CellType.OPTIONAL)
def write_cell_data(self): value = self._random.choice([ '# something', 'foobar', ': FOR', '${var}', 'No Operation', '\\', 'zoo%d' % self._rand(), '${%d}' % self._rand() ]) self._macro_execute( ChangeCellValue(self._rand_row(), self._rand_col(), value))
def test_create_and_remove_keyword(self): kw_name = 'Super Keyword' self.test.execute(ChangeCellValue(0, 0, kw_name)) self._verify_cell_info(0, 0, ContentType.STRING, CellType.KEYWORD) self.test.execute(AddKeyword(kw_name, '${argh}')) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.EMPTY, CellType.MANDATORY) self.test.execute(Undo()) self._verify_cell_info(0, 0, ContentType.STRING, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.EMPTY, CellType.UNKNOWN)
def test_modify_last_step_so_that_it_should_be_empty_and_not_part_of_for_loop( self): test = self.chief.datafiles[1].tests[8] test.execute(ChangeCellValue(2, 0, '')) self._steps_are_not_in_for_loop(test, 2)
def _verify_string_change(self, row, col, celltype): self._verify_cell_info(row, col, ContentType.EMPTY, celltype) self.test.execute(ChangeCellValue(row, col, 'diipadaapa')) self._verify_cell_info(row, col, ContentType.STRING, celltype)
def test_keyword_without_args(self): self.test.execute(ChangeCellValue(0, 0, self.keyword3.name)) self._verify_cell_info(0, 0, ContentType.USER_KEYWORD, CellType.KEYWORD) self._verify_cell_info(0, 1, ContentType.EMPTY, CellType.MUST_BE_EMPTY)
def test_library_import_with_name(self): self.test.execute(ChangeCellValue(0, 0, 'alias3.Onething')) self._verify_cell_info(0, 0, ContentType.STRING, CellType.KEYWORD) self.testsuite.imports.add_library('libi.py', [], 'alias3') self._verify_cell_info(0, 0, ContentType.LIBRARY_KEYWORD, CellType.KEYWORD)
def test_adding_new_for_loop(self): test2 = self.chief.datafiles[1].tests[1] test2.execute(ChangeCellValue(0, 0, ':FOR')) self.assertTrue(isinstance(test2.step(0), ForLoopStepController), 'wrong type of step type (%s)' % type(test2.step(0)))
def test_for_loop_change_and_purify(self): test = self.chief.datafiles[1].tests[13] test.execute(ChangeCellValue(1, 2, '')) test.execute(Purify()) self._steps_are_in_for_loop(test, 2)
def test_adding_step_to_for_loop(self): test = self.chief.datafiles[1].tests[0] test.execute(ChangeCellValue(4, 1, 'No Operation')) self.assertTrue(isinstance(test.step(4), IntendedStepController), 'wrong type of step type (%s)' % type(test.step(4)))
def test_empty_column_before_string_is_string(self): self.test.execute(ChangeCellValue(0, 0, self.keyword1.name)) self.test.execute(ChangeCellValue(0, 2, 'something')) self._verify_cell_info(0, 1, ContentType.STRING, CellType.MANDATORY)
def test_removing_step_in_middle_from_for_loop(self): test = self.chief.datafiles[1].tests[5] test.execute(ChangeCellValue(2, 0, 'Something')) self._steps_are_in_for_loop(test, 1) self._steps_are_not_in_for_loop(test, 2, 3) self._steps_first_cells_are_empty(test, 1, 3)
def write_cell_data(self): prefix = self._random.choice( ['# something', 'foobar', ': FOR', '${var}', 'No Operation', '\\']) self._macro_execute( ChangeCellValue(self._rand_row(), self._rand_col(), prefix + str(self._rand())))
def test_removing_first_step_from_for_loop(self): test = self.chief.datafiles[1].tests[6] test.execute(ChangeCellValue(1, 0, 'Invalidate all')) self._steps_are_not_in_for_loop(test, 1, 2, 3) self._steps_first_cells_are_empty(test, 2, 3)
def test_removing_last_step_from_for_loop(self): test = self.chief.datafiles[1].tests[7] test.execute(ChangeCellValue(3, 0, 'Something')) self._steps_are_in_for_loop(test, 1, 2) self._steps_are_not_in_for_loop(test, 3) self._steps_first_cells_are_empty(test, 1, 2)
def cell_value_edited(self, row, col, value): self._execute(ChangeCellValue(row, col, value))
def _add_step(self, keyword): self.test_ctrl.execute(ChangeCellValue(100, 100, keyword)) self._steps_have_changed = False
def test_empty_normal_step_first_cell(self): test = self.chief.datafiles[1].tests[9] test.execute(ChangeCellValue(0, 0, '')) self._steps_are_not_in_for_loop(test, 0)