Beispiel #1
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_equals(self._error_message,
                   ERROR_FILE_ALREADY_EXISTS % "jup.txt")
Beispiel #2
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_equals(self._error_message, ERROR_FILE_ALREADY_EXISTS % "jup.txt")
Beispiel #3
0
 def test_rename_empty_name_error(self):
     RenameFile("").execute(self._create_controller())
     assert_equals(self._error_message, ERROR_EMPTY_FILENAME)
Beispiel #4
0
 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)
Beispiel #5
0
 def test_rename_publishes_message(self):
     RenameFile('some').execute(self._create_controller())
     assert_equals(self._error_message, None)
     assert_equals(self._message, self.ctrl)
Beispiel #6
0
 def test_rename_illegal_character_error(self):
     RenameFile("dsk\//\sdfj$''lkfdsjflk$'\'fdslkjlsuite....").execute(
         self._create_controller())
     assert_equals(self._error_message, ERROR_ILLEGAL_CHARACTERS)
Beispiel #7
0
 def test_rename_saves_file(self):
     RenameFile('quux').execute(self._create_controller())
     assert_equals(self._error_message, None)
     assert_true(self.saved is True)
Beispiel #8
0
 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)
Beispiel #9
0
 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')))
Beispiel #10
0
 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)
Beispiel #11
0
 def _rename_command(self, label):
     return RenameFile(label)