def save(self, document):
     '''Save the given `document`.'''
     assert isinstance(document, Document)
     existing = list(self._documents.find({'name': document.name}))
     if len(existing) > 0:
         raise self._exists(document.name)
     self._documents.insert(Document.to_dict(document))
Esempio n. 2
0
 def test_to_dict(self):
     A = Document(self.name(), self.text(), self.metadata())
     self.assertEqual(Document.to_dict(A), self.dictionary())