Skip to content

Commit

Permalink
Fix unit tests for ReplaceOccurrences tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HelioGuilherme66 committed Dec 18, 2024
1 parent 4b7c23d commit c9db1eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/robotide/controller/filecontrollers.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ def is_directory_suite(self):
def resource_import_modified(self, path):
return self._project.resource_import_modified(path, self.directory)

def notify_settings_changed(self):
def notify_settings_changed(self, old_name=None):
_ = old_name
RideItemSettingsChanged(item=self).publish()

def notify_steps_changed(self):
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/controller/macrocontrollers.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ def notify_keyword_removed(self):
RideUserKeywordRemoved(datafile=self.datafile, name=self.name, item=self).publish()
self.notify_steps_changed()

def notify_settings_changed(self):
def notify_settings_changed(self, old_name=None):
_ = old_name
self.update_namespace()
self._notify(RideItemSettingsChanged)

Expand Down
4 changes: 2 additions & 2 deletions src/robotide/controller/settingcontrollers.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def set_comment(self, comment):
self._data.comment = comment
self.mark_dirty()

def notify_value_changed(self):
self._parent.notify_settings_changed()
def notify_value_changed(self, old_name=None):
self._parent.notify_settings_changed(old_name)

def clear(self):
self._data.reset()
Expand Down
23 changes: 11 additions & 12 deletions utest/controller/test_occurrences.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ def _expected_messages(self, steps_have_changed=False,
testcase_settings_have_changed=False,
name_has_changed=False):
assert self._steps_have_changed == steps_have_changed
assert (self._testcase_settings_have_changed ==
testcase_settings_have_changed)
assert self._testcase_settings_have_changed == testcase_settings_have_changed
assert self._name_has_changed == name_has_changed

def _rename(self, original_name, new_name, source, usage):
Expand Down Expand Up @@ -482,12 +481,12 @@ def steps_changed_check_that_name_has_also(message):

def test_rename_in_steps(self):
self._rename(STEP1_KEYWORD, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)

def test_rename_with_dollar_sign(self):
self._rename(STEP1_KEYWORD, UNUSED_KEYWORD_NAME+'$', TEST1_NAME,
'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)

def test_undo_rename_in_step(self):
self._rename(STEP1_KEYWORD, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
Expand All @@ -501,7 +500,7 @@ def test_undo_after_renaming_to_something_that_is_already_there(self):

def test_rename_steps_argument(self):
self._rename(STEP2_ARGUMENT, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
assert self.test_ctrl.steps[1].as_list() == ['Run Keyword',
UNUSED_KEYWORD_NAME]

Expand Down Expand Up @@ -544,53 +543,53 @@ def test_rename_in_suite_test_template(self):
def test_rename_in_user_keywords(self):
self._rename(KEYWORD_IN_USERKEYWORD1, UNUSED_KEYWORD_NAME,
USERKEYWORD1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)

def test_rename_given_prefixed_keywords(self):
kw = 'BLOdkajasdj'
self._add_step('Given '+kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
'Given '+UNUSED_KEYWORD_NAME)

def test_rename_when_prefixed_keywords(self):
kw = 'fjsdklhf37849'
self._add_step('wHEn '+kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
'wHEn '+UNUSED_KEYWORD_NAME)

def test_rename_then_prefixed_keywords(self):
kw = 'djkfsekrhnbdxcvzo dsjah'
self._add_step('THen '+kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
'THen '+UNUSED_KEYWORD_NAME)

def test_rename_and_prefixed_keywords(self):
kw = 'mmxznbfje uiriweyi yr iu fjkdhzxck'
self._add_step('AND '+kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
'AND '+UNUSED_KEYWORD_NAME)

def test_rename_but_prefixed_keywords(self):
kw = 'sdlmclkds dslcm ldsm sdclmklm'
self._add_step('bUt '+kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
'bUt '+UNUSED_KEYWORD_NAME)

def test_rename_when_keyword_begins_with_prefix(self):
kw = 'When I say so'
self._add_step(kw)
self._rename(kw, UNUSED_KEYWORD_NAME, TEST1_NAME, 'Steps')
self._expected_messages(steps_have_changed=True)
self._expected_messages(steps_have_changed=True, name_has_changed=True)
self.assertEqual(self.test_ctrl.step(100).as_list()[100],
UNUSED_KEYWORD_NAME)

Expand Down

0 comments on commit c9db1eb

Please sign in to comment.