Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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'])
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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'])
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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'))
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 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))
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 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)))
Ejemplo n.º 21
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)
Ejemplo n.º 22
0
 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)))
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
 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)
Ejemplo n.º 25
0
 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())))
Ejemplo n.º 26
0
 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)
Ejemplo n.º 27
0
 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)
Ejemplo n.º 28
0
 def cell_value_edited(self, row, col, value):
     self._execute(ChangeCellValue(row, col, value))
Ejemplo n.º 29
0
 def _add_step(self, keyword):
     self.test_ctrl.execute(ChangeCellValue(100, 100, keyword))
     self._steps_have_changed = False
Ejemplo n.º 30
0
 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)