Beispiel #1
0
 def test_remote_resources(self):
     """Test syncing remote resources"""
     remote = self._create_remote_note(
         resources=[ttypes.Resource(
             data=ttypes.Data(body=open(resource_path).read()),
             mime='image/png',
             attributes=ttypes.ResourceAttributes(
                 fileName='test.png',
             )
         )],
     )
     self.sync.notes_remote()
     resource = self.sq(Note).filter(
         Note.guid == remote.guid,
     ).one().resources[0]
     self.assertEqual(
         'test.png', resource.file_name,
     )
     remote.resources = None
     self.note_store.updateNote(self.auth_token, remote)
     self.sync.notes_remote()
     with self.assertRaises(NoResultFound):
         # fetch synchronized not very genius, but we don't need that
         get_db_session().query(Resource).filter(
             Resource.guid == resource.guid,
         ).one()
Beispiel #2
0
    def on_remove_authenticated(self):

        self.logger.debug("Signal to remove authenticate")
        self.sync_thread.timer.stop()
        self.sync_thread.quit()
        self.sync_thread.update_count = 0

        # delete_auth_token - enauth.py        
        delete_auth_token( )
        
        # get_db_sesson everpad/provider/tools.py        
        session = get_db_session()

        session.query(everpad.provider.models.Note).delete(
            synchronize_session='fetch',
        )
        session.query(everpad.provider.models.Resource).delete(
            synchronize_session='fetch',
        )
        session.query(everpad.provider.models.Notebook).delete(
            synchronize_session='fetch',
        )
        session.query(everpad.provider.models.Tag).delete(
            synchronize_session='fetch',
        )
        session.commit()
Beispiel #3
0
 def setUp(self):
     self.service = ProviderService()
     self.session = get_db_session()
     self.service._session = self.session
     self.service.qobject = MagicMock()
     self.service.app = MagicMock()
     self.service.sync = MagicMock()
Beispiel #4
0
 def on_remove_authenticated(self):
     self.sync_thread.quit()
     set_auth_token('')
     session = get_db_session()
     session.query(models.Note).delete(synchronize_session='fetch', )
     session.query(models.Resource).delete(synchronize_session='fetch', )
     session.query(models.Notebook).delete(synchronize_session='fetch', )
     session.query(models.Tag).delete(synchronize_session='fetch', )
     session.commit()
Beispiel #5
0
 def setUp(self):
     self.service = ProviderService()
     self.session = get_db_session()
     self.service._session = self.session
     models.Note.session = self.session
     self.service.qobject = MagicMock()
     self.service.app = MagicMock()
     self.service.sync = MagicMock()
     factories.invoke_session(self.session)
Beispiel #6
0
 def setUp(self):
     self.service = ProviderService()
     self.session = get_db_session()
     self.service._session = self.session
     models.Note.session = self.session
     self.service.qobject = MagicMock()
     self.service.app = MagicMock()
     self.service.sync = MagicMock()
     factories.invoke_session(self.session)
Beispiel #7
0
 def run(self):
     self.session = get_db_session()
     self.sq = self.session.query
     self.auth_token = get_auth_token()
     self.note_store = get_note_store(self.auth_token)
     self.perform()
     while True:
         self.mutex.lock()
         self.wait_condition.wait(self.mutex)
         self.perform()
         self.mutex.unlock()
Beispiel #8
0
 def setUp(self):
     self.session = get_db_session(':memory:')
     self.store = get_note_store(token)
     self.sc = SyncThread()
     self.sc.session = self.session
     self.sc.sq = self.session.query
     self.sc.note_store = self.store
     self.sc.auth_token = token
     self.serv = ProviderService()
     self.serv._session = self.session
     models.Note.session = self.session  # hack for test
Beispiel #9
0
 def setUp(self):
     self.session = get_db_session(':memory:')
     self.store = get_note_store(token)
     self.sc = SyncThread()
     self.sc.session = self.session
     self.sc.sq = self.session.query
     self.sc.note_store = self.store
     self.sc.auth_token = token
     self.serv = ProviderService()
     self.serv._session = self.session
     models.Note.session = self.session  # hack for test
Beispiel #10
0
 def __init__(self):
     self.logs = []
     self.app = type('fake', (object,), {
         'log': self.log,
     })
     self.update_count = 0
     self.session = get_db_session()
     self.sq = self.session.query
     self.auth_token = TOKEN
     self.note_store = note_store
     if self._need_to_update():
         self.need_to_update = True
     else:
         self.need_to_update = False
Beispiel #11
0
 def test_remote_notes(self):
     """Test syncing remote notes"""
     remote = self._create_remote_note()
     self.sync.notes_remote()
     note = self.sq(Note).filter(
         Note.guid == remote.guid,
     ).one()
     self.assertEqual(note.title, remote.title)
     remote.title += '*'
     remote.updated = int(time.time() * 1000)
     self.note_store.updateNote(self.auth_token, remote)
     self.sync.notes_remote()
     note = self.sq(Note).filter(
         Note.guid == remote.guid,
     ).one()
     self.assertEqual(note.title, remote.title)
     self.note_store.deleteNote(self.auth_token, note.guid)
     self.sync.notes_remote()
     with self.assertRaises(NoResultFound):
         # fetch synchronized not very genius, but we don't need that
         get_db_session().query(Note).filter(
             Note.guid == remote.guid,
         ).one()
Beispiel #12
0
 def on_remove_authenticated(self):
     self.sync_thread.quit()
     set_auth_token('')
     session = get_db_session()
     session.query(models.Note).delete(
         synchronize_session='fetch',
     )
     session.query(models.Resource).delete(
         synchronize_session='fetch',
     )
     session.query(models.Notebook).delete(
         synchronize_session='fetch',
     )
     session.query(models.Tag).delete(
         synchronize_session='fetch',
     )
     session.commit()
Beispiel #13
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session
     self.app = app
     app.update(self.service)
     notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None),
     )
     self.note = Note.from_tuple(self.service.create_note(Note(
         id=NONE_ID,
         title='New note',
         content="New note content",
         tags=[],
         notebook=notebook.id,
         created=NONE_VAL,
         updated=NONE_VAL,
         place='',
     ).struct))
Beispiel #14
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session
     self.app = app
     self.app.update(self.service)
     notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None),
     )
     self.note = Note.from_tuple(self.service.create_note(Note(
         id=NONE_ID,
         title='New note',
         content="New note content",
         tags=[],
         notebook=notebook.id,
         created=NONE_VAL,
         updated=NONE_VAL,
         place='',
     ).struct))
Beispiel #15
0
    def on_remove_authenticated(self):

        self.logger.debug("Signal to remove authenticate")
        self.sync_thread.timer.stop()
        self.sync_thread.quit()
        self.sync_thread.update_count = 0

        # delete_auth_token - enauth.py
        delete_auth_token()

        # get_db_sesson everpad/provider/tools.py
        session = get_db_session()

        session.query(everpad.provider.models.Note).delete(
            synchronize_session='fetch', )
        session.query(everpad.provider.models.Resource).delete(
            synchronize_session='fetch', )
        session.query(everpad.provider.models.Notebook).delete(
            synchronize_session='fetch', )
        session.query(everpad.provider.models.Tag).delete(
            synchronize_session='fetch', )
        session.commit()
Beispiel #16
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
     self.session = self.service._session
Beispiel #17
0
 def _create_service(self):
     """Create service"""
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
Beispiel #18
0
 def _create_service(self):
     """Create service"""
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
Beispiel #19
0
 def session(self):
     if not hasattr(self, '_session'):
         self._session = get_db_session()
         Note.session = self._session  # shit shit
     return self._session
Beispiel #20
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
     self.session = self.service._session
Beispiel #21
0
 def session(self):
     if not hasattr(self, '_session'):
         self._session = get_db_session()
         Note.session = self._session   # shit shit
     return self._session
Beispiel #22
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
     self.notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None),
     )
     self.notebook2 = Notebook.from_tuple(
         self.service.create_notebook('test2', None),
     )
     self.notebook3 = Notebook.from_tuple(
         self.service.create_notebook(u'Блокнот', None),
     )
     notes = [
         self.service.create_note(Note(
             id=NONE_ID,
             title='New note',
             content="New note content",
             tags=['ab', 'cd'],
             notebook=self.notebook.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place='first',
             pinnded=False,
         ).struct),
         self.service.create_note(Note(
             id=NONE_ID,
             title='Old note',
             content="Old note content",
             tags=['ef', 'gh'],
             notebook=self.notebook2.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place='second',
             pinnded=False,
         ).struct),
         self.service.create_note(Note(
             id=NONE_ID,
             title='not',
             content="oke",
             tags=['ab', 'gh'],
             notebook=self.notebook.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place='second',
             pinnded=True,
         ).struct),
         self.service.create_note(Note(
             id=NONE_ID,
             title=u'Заметка',
             content=u"Заметка",
             tags=[u'тэг'],
             notebook=self.notebook.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place=u'место',
             pinnded=False,
         ).struct),
         self.service.create_note(Note(
             id=NONE_ID,
             title=u'заметка',
             content=u"заметка",
             tags=[u'тэг'],
             notebook=self.notebook.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place=u'место',
             pinnded=False,
         ).struct),
     ]
     self.notes = map(lambda note:
         Note.from_tuple(self.service.update_note(note)),
     notes)
Beispiel #23
0
 def _create_db_session(self):
     """Create database session"""
     self.session = get_db_session()
Beispiel #24
0
 def init_db(self):
     self.session = get_db_session()
     self.sq = self.session.query
Beispiel #25
0
 def _create_db_session(self):
     """Create database session"""
     self.session = get_db_session()
     factories.invoke_session(self.session)
Beispiel #26
0
 def _create_db_session(self):
     """Create database session"""
     self.session = get_db_session()
     factories.invoke_session(self.session)
Beispiel #27
0
 def init_db(self):
     self.session = get_db_session()
     self.sq = self.session.query
Beispiel #28
0
 def setUp(self):
     self.service = ProviderService()
     self.service._session = get_db_session()
     models.Note.session = self.service._session  # TODO: fix that shit
     self.notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None), )
     self.notebook2 = Notebook.from_tuple(
         self.service.create_notebook('test2', None), )
     self.notebook3 = Notebook.from_tuple(
         self.service.create_notebook(u'Блокнот', None), )
     notes = [
         self.service.create_note(
             Note(
                 id=NONE_ID,
                 title='New note',
                 content="New note content",
                 tags=['ab', 'cd'],
                 notebook=self.notebook.id,
                 created=NONE_VAL,
                 updated=NONE_VAL,
                 place='first',
                 pinnded=False,
             ).struct),
         self.service.create_note(
             Note(
                 id=NONE_ID,
                 title='Old note',
                 content="Old note content",
                 tags=['ef', 'gh'],
                 notebook=self.notebook2.id,
                 created=NONE_VAL,
                 updated=NONE_VAL,
                 place='second',
                 pinnded=False,
             ).struct),
         self.service.create_note(
             Note(
                 id=NONE_ID,
                 title='not',
                 content="oke",
                 tags=['ab', 'gh'],
                 notebook=self.notebook.id,
                 created=NONE_VAL,
                 updated=NONE_VAL,
                 place='second',
                 pinnded=True,
             ).struct),
         self.service.create_note(
             Note(
                 id=NONE_ID,
                 title=u'Заметка',
                 content=u"Заметка",
                 tags=[u'тэг'],
                 notebook=self.notebook.id,
                 created=NONE_VAL,
                 updated=NONE_VAL,
                 place=u'место',
                 pinnded=False,
             ).struct),
         self.service.create_note(
             Note(
                 id=NONE_ID,
                 title=u'заметка',
                 content=u"заметка",
                 tags=[u'тэг'],
                 notebook=self.notebook.id,
                 created=NONE_VAL,
                 updated=NONE_VAL,
                 place=u'место',
                 pinnded=False,
             ).struct),
     ]
     self.notes = map(
         lambda note: Note.from_tuple(self.service.update_note(note)),
         notes)