def test_empty_01(self): ''' Wiki is not added to Application ''' watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_01(self): ''' Wiki is not added to Application ''' watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_03(self): ''' Wiki added to Application _after_ AttachWatcher initializing. No selected pages. ''' watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.wikiroot = self.wikiroot wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_race_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) watcher = AttachWatcher(self._application, 500) watcher.initialize() self._application.selectedPage = self.page_02 wx.MilliSleep(1000) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_add_files_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._attach_files(self.page_01, ['add.png']) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)
def test_rename_page_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self.page_01.title = 'Новый заголовок' wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_rename_page_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self.page_01.title = 'Новый заголовок' wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_race_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) watcher = AttachWatcher(self._application, 500) watcher.initialize() self._application.selectedPage = self.page_02 wx.MilliSleep(1000) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_add_files_01(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._attach_files(self.page_01, ['add.png']) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)
def test_empty_10_create_empty_attach_dir(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() Attachment(self._application.selectedPage).getAttachPath(True) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_10_create_empty_attach_dir(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() Attachment(self._application.selectedPage).getAttachPath(True) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_03(self): ''' Wiki added to Application _after_ AttachWatcher initializing. No selected pages. ''' watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.wikiroot = self.wikiroot wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_04(self): ''' Wiki added to Application _before_ AttachWatcher initializing. Selected page. ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_04(self): ''' Wiki added to Application _before_ AttachWatcher initializing. Selected page. ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_08(self): ''' Change the selected page ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.selectedPage = self.page_02 wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_attach_touch_write(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() attach = Attachment(self.page_01) with open(attach.getFullPath('add.png'), 'w'): pass wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_attach_touch_write(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() attach = Attachment(self.page_01) with open(attach.getFullPath('add.png'), 'w'): pass wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_remove_empty_attach_dir(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 attach = Attachment(self.page_01) attach_dir = attach.getAttachPath(True) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() shutil.rmtree(attach_dir) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_remove_empty_attach_dir(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 attach = Attachment(self.page_01) attach_dir = attach.getAttachPath(True) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() shutil.rmtree(attach_dir) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_09_close_wiki(self): ''' Close current notes tree ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.wikiroot = None wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_09_close_wiki(self): ''' Close current notes tree ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.wikiroot = None wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_empty_08(self): ''' Change the selected page ''' self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() self._application.selectedPage = self.page_02 wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 0)
def test_attach_rename(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) attach = Attachment(self.page_01) src_fname = attach.getFullPath('add.png') dest_fname = attach.getFullPath('newname.png') watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() os.rename(src_fname, dest_fname) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)
def test_switch_and_add_file(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) self._attach_files(self.page_02, ['add.png', 'dir.png']) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() # Switch pages self._application.selectedPage = self.page_02 self._attach_files(self.page_02, ['accept.png']) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)
def test_switch_and_add_file(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) self._attach_files(self.page_02, ['add.png', 'dir.png']) watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() # Switch pages self._application.selectedPage = self.page_02 self._attach_files(self.page_02, ['accept.png']) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)
def test_attach_rename(self): self._application.wikiroot = self.wikiroot self._application.selectedPage = self.page_01 self._attach_files(self.page_01, ['add.png']) attach = Attachment(self.page_01) src_fname = attach.getFullPath('add.png') dest_fname = attach.getFullPath('newname.png') watcher = AttachWatcher(self._application, self._period_ms) watcher.initialize() os.rename(src_fname, dest_fname) wx.MilliSleep(500) self.myYield() watcher.clear() self.assertEqual(self._eventCount, 1)