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_equals(self._error_message, ERROR_FILE_ALREADY_EXISTS % "jup.txt")
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_equals(self._error_message, ERROR_FILE_ALREADY_EXISTS % "jup.txt")
def test_rename_empty_name_error(self): RenameFile("").execute(self._create_controller()) assert_equals(self._error_message, ERROR_EMPTY_FILENAME)
def test_rename_newlines_in_name_error(self): RenameFile("ashdjashdhjasd\nasdads").execute(self._create_controller()) assert_equals(self._error_message, ERROR_NEWLINES_IN_THE_FILENAME)
def test_rename_publishes_message(self): RenameFile('some').execute(self._create_controller()) assert_equals(self._error_message, None) assert_equals(self._message, self.ctrl)
def test_rename_illegal_character_error(self): RenameFile("dsk\//\sdfj$''lkfdsjflk$'\'fdslkjlsuite....").execute( self._create_controller()) assert_equals(self._error_message, ERROR_ILLEGAL_CHARACTERS)
def test_rename_saves_file(self): RenameFile('quux').execute(self._create_controller()) assert_equals(self._error_message, None) assert_true(self.saved is True)
def test_rename_deletes_old_path(self): RenameFile('quux').execute(self._create_controller()) assert_equals(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_equals(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_equals(self._error_message, None) assert_equals(self.ctrl.filename, 'quux.txt') assert_equals(self.ctrl.data.source, self.ctrl.filename)
def _rename_command(self, label): return RenameFile(label)