def test_create_new_empty_name(self): mocker = mox.Mox() settings = mocker.CreateMock(BaseSettings) view = mocker.CreateMock(MainWindow) settings.get('Options', 'DataDir').AndReturn('') settings.get('Notes', 'Opened').AndReturn('') view.ask_note_name().AndReturn('') mocker.ReplayAll() model = App(settings) c = NotesController(model, settings, view, Path('./tests/dummy/subdummy')) c.create_new() self.assertEquals(1, len(model.notes))
class MainController(BaseMainController): def __init__(self, main_script): font = wx.NORMAL_FONT BaseMainController.__init__(self, main_script, meta, config) self.view = MainWindow() self.settings = BaseSettings(self.settings_path, SETTINGS_DEFAULTS) self.model = App(self.settings) self.notes = NotesController(self.model, self.settings, self.view, self.settings_path.parent) self.commands = CommandController(self, self.settings) self.view.load_position(self.settings) pub.subscribe(self.on_program_closed, 'program.closed') pub.subscribe(self.on_page_key_down, 'page.key_down') pub.subscribe(self.on_options_changing, 'options.changing') #TODO: use call after? handle exceptions self.notes.open_initial() def quit(self): self.view.Close() def open_options(self): opt = Options() opt.read(self.settings) self.view.open_options(opt) def hide(self): self.notes.save(self.view.pages) self.notes.save_opened(self.view.pages) self.view.hide() def find(self): self.view.find() def delete_line(self): pub.sendMessage('note.edit.delete_line') def on_program_closed(self, pages): self.view.save_position(self.settings) self.notes.save_opened(pages) self.settings.save() logging.shutdown() def on_page_key_down(self, key_code, flags): if key_code == wx.WXK_ESCAPE: self.hide() def on_options_changing(self, options): if options.modifiers is None or options.key_code is None: hotkey = '' else: hotkey = '%d,%d' % (options.modifiers, options.key_code) self.settings.set('Options', 'HotKey', hotkey) self.settings.set('Options', 'Font', options.font)
def test_open_initial(self): mocker = mox.Mox() settings = mocker.CreateMock(BaseSettings) note = mocker.CreateMock(Note) view = mocker.CreateMockAnything() note.name = 'Name' settings.get('Options', 'DataDir').AndReturn('') settings.get('Notes', 'Opened').AndReturn('') settings.get('Notes', 'CurrentOpened').AndReturn('Name') note.open(create=True) mocker.ReplayAll() model = App(settings) c = NotesController(model, settings, view, Path('./tests/dummy/nonotes')) model.notes = [note] c.open_initial()
def __init__(self, main_script): font = wx.NORMAL_FONT BaseMainController.__init__(self, main_script, meta, config) self.view = MainWindow() self.settings = BaseSettings(self.settings_path, SETTINGS_DEFAULTS) self.model = App(self.settings) self.notes = NotesController(self.model, self.settings, self.view, self.settings_path.parent) self.commands = CommandController(self, self.settings) self.view.load_position(self.settings) pub.subscribe(self.on_program_closed, 'program.closed') pub.subscribe(self.on_page_key_down, 'page.key_down') pub.subscribe(self.on_options_changing, 'options.changing') #TODO: use call after? handle exceptions self.notes.open_initial()