Permalink
Browse files

fix warnings from test suite

  • Loading branch information...
diogomatsubara committed Sep 3, 2013
1 parent 2f0d711 commit c823121e4c5885b2715a129e52c217495d7f5d56
Showing with 32 additions and 17 deletions.
  1. +1 −0 .gitignore
  2. +14 −8 everpad/provider/sync/note.py
  3. +9 −4 everpad/provider/sync/notebook.py
  4. +8 −5 everpad/provider/sync/tag.py
View
@@ -1,5 +1,6 @@
syntax: glob
*.swp
*.pyc
*pip-delete-this-directory.txt
/build
@@ -172,7 +172,8 @@ def pull(self):
self._check_sharing_information(note, note_ttype)
resource_ids = self._receive_resources(note, note_ttype)
self._remove_resources(note, resource_ids)
if resource_ids:
self._remove_resources(note, resource_ids)
self.session.commit()
self._remove_notes()
@@ -240,13 +241,18 @@ def _create_conflict(self, note, note_ttype):
def _remove_notes(self):
"""Remove not exists notes"""
self.session.query(models.Note).filter((
~models.Note.id.in_(self._exists)
| ~models.Note.conflict_parent_id.in_(self._exists)
) & ~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT,
))).delete(synchronize_session='fetch')
if self._exists:
q = ((~models.Note.id.in_(self._exists) |
~models.Note.conflict_parent_id.in_(self._exists)) &
~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT)))
else:
q = (~models.Note.action.in_((
const.ACTION_NOEXSIST, const.ACTION_CREATE,
const.ACTION_CHANGE, const.ACTION_CONFLICT)))
self.session.query(models.Note).filter(q).delete(
synchronize_session='fetch')
self.session.commit()
def _receive_resources(self, note, note_ttype):
@@ -142,8 +142,13 @@ def _update_notebook(self, notebook_ttype):
def _remove_notebooks(self):
"""Remove not received notebooks"""
if self._exists:
q = (~models.Notebook.id.in_(self._exists)
& (models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE))
else:
q = ((models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE))
self.session.query(models.Notebook).filter(
~models.Notebook.id.in_(self._exists)
& (models.Notebook.action != const.ACTION_CREATE)
& (models.Notebook.action != const.ACTION_CHANGE)
).delete(synchronize_session='fetch')
q).delete(synchronize_session='fetch')
@@ -90,7 +90,7 @@ def pull(self):
self._remove_tags()
def _create_tag(self, tag_ttype):
"""Create notebook from server"""
"""Create tag from server"""
tag = models.Tag(guid=tag_ttype.guid)
tag.from_api(tag_ttype)
self.session.add(tag)
@@ -108,7 +108,10 @@ def _update_tag(self, tag_ttype):
def _remove_tags(self):
"""Remove not exist tags"""
self.session.query(models.Tag).filter(
~models.Tag.id.in_(self._exists)
& (models.Tag.action != const.ACTION_CREATE)
).delete(synchronize_session='fetch')
if self._exists:
q = (~models.Tag.id.in_(self._exists)
& (models.Tag.action != const.ACTION_CREATE))
else:
q = (models.Tag.action != const.ACTION_CREATE)
self.session.query(models.Tag).filter(q).delete(
synchronize_session='fetch')

0 comments on commit c823121

Please sign in to comment.