Esempio n. 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")
Esempio n. 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")
Esempio n. 3
0
 def test_rename_empty_name_error(self):
     RenameFile("").execute(self._create_controller())
     assert_equals(self._error_message, ERROR_EMPTY_FILENAME)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')))
Esempio n. 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)
Esempio n. 11
0
 def _rename_command(self, label):
     return RenameFile(label)