def _open_editor_with_note(note, editor=None): try: editor_exec = utils.get_editor(custom_editor=editor) except utils.NotEditorFoundError as reason: print(reason) exit(-1) cmd = [editor_exec, utils.get_note_path(note)] subprocess.call(cmd)
def test_get_editor_custom_raises(self): with mock.patch('notas.utils.shutil.which', return_value=None): with self.assertRaises(utils.NotEditorFoundError): utils.get_editor('algun_editor')
def test_get_editor_custom(self): with mock.patch('notas.utils.shutil.which', return_value='ninja-ide'): self.assertEqual(utils.get_editor('ninja-ide'), 'ninja-ide')
def test_get_editor_not_environ_default_raises(self): with mock.patch('notas.utils.os.environ', {'EDITOR': None}): with mock.patch('notas.utils.shutil.which', return_value=None): with self.assertRaises(utils.NotEditorFoundError): utils.get_editor()
def test_get_editor_not_environ_default_ok(self): with mock.patch('notas.utils.os.environ', {'EDITOR': None}): with mock.patch('notas.utils.shutil.which', return_value='/usr/bin/editor'): self.assertEqual(utils.get_editor(), '/usr/bin/editor')
def test_get_editor_environ_ok(self): with mock.patch('notas.utils.os.environ', {'EDITOR': 'super_editor'}): self.assertEqual(utils.get_editor(), 'super_editor')