def test_rename_already_existing_error(self):
     rename_command = RenameFile("jup")
     rename_command._validator._file_exists = lambda *_: True
     rename_command.execute(self._create_controller())
     assert_equal(self._error_message,
                  ERROR_FILE_ALREADY_EXISTS % "jup.txt")
Example #2
0
 def _rename_command(self, label):
     return RenameFile(label)
 def test_rename_empty_name_error(self):
     RenameFile("").execute(self._create_controller())
     assert_equal(self._error_message, ERROR_EMPTY_FILENAME)
 def test_rename_newlines_in_name_error(self):
     RenameFile("ashdjashdhjasd\nasdads").execute(self._create_controller())
     assert_equal(self._error_message, ERROR_NEWLINES_IN_THE_FILENAME)
 def test_rename_publishes_message(self):
     RenameFile('some').execute(self._create_controller())
     assert_equal(self._error_message, None)
     assert_equal(self._message, self.ctrl)
 def test_rename_illegal_character_error(self):
     RenameFile("dsk\dà°¨\j$''lkfd\{sjflk$'\'fdslkjl\[\]suite....").execute(
         self._create_controller())
     assert_equal(self._error_message, ERROR_ILLEGAL_CHARACTERS)
 def test_rename_saves_file(self):
     RenameFile('quux').execute(self._create_controller())
     assert_equal(self._error_message, None)
     assert_true(self.saved is True)
 def test_rename_deletes_old_path(self):
     RenameFile('quux').execute(self._create_controller())
     assert_equal(self._error_message, None)
     assert_true(self.deleted is True)
 def test_rename_preserves_directory_path(self):
     RenameFile('quux').execute(self._create_controller('foo/bar.html'))
     assert_equal(self._error_message, None)
     assert_true(
         self.ctrl.filename.endswith(os.path.join('foo', 'quux.html')))
 def test_rename_changes_basename_but_keeps_extension(self):
     RenameFile('quux').execute(self._create_controller())
     assert_equal(self._error_message, None)
     assert_equal(self.ctrl.filename, 'quux.txt')
     assert_equal(self.ctrl.data.source, self.ctrl.filename)
Example #11
0
 def test_rename_already_existing_error(self):
     rename_command = RenameFile("jup")
     rename_command._validator._file_exists = lambda *_: True
     rename_command.execute(self._create_controller())
     assert_equal(self._error_message, ERROR_FILE_ALREADY_EXISTS % "jup.txt")