Example #1
0
    def test_notify_new_document(self):
        from lembrar import plugins
        entry_point = MagicMock()

        def fake_entry_points(group):
            return [entry_point]

        plugins.iter_entry_points = fake_entry_points
        plugins.notify_new_document('docid')
        assert [call.load(), call.load()(initial=False, docids=['docid'
                ])] == entry_point.mock_calls
Example #2
0
    def test_notify_new_document(self):
        from lembrar import plugins
        entry_point = MagicMock()

        def fake_entry_points(group):
            return [entry_point]

        plugins.iter_entry_points = fake_entry_points
        plugins.notify_new_document('docid')
        assert [call.load(),
                call.load()(initial=False,
                            docids=['docid'])] == entry_point.mock_calls
Example #3
0
    def add_one(self, file_reader, created, **kw):
        '''Add one document, store all kwargs on it
        :param file_reader: The file data
        :type file_reader: An object that can be read from
        :param created: The time, the object got created
        :type created: datetime object without tz info and utc time
        '''

        params = dict(created=created, raw_data=self.grid.put(file_reader))
        for (key, value) in kw.items():
            params[key] = value
        docid = self.db.docs.insert(params)
        notify_new_document(docid)
        return docid
Example #4
0
    def add_one(
        self,
        file_reader,
        created,
        **kw
        ):
        '''Add one document, store all kwargs on it
        :param file_reader: The file data
        :type file_reader: An object that can be read from
        :param created: The time, the object got created
        :type created: datetime object without tz info and utc time
        '''

        params = dict(created=created,
                      raw_data=self.grid.put(file_reader))
        for (key, value) in kw.items():
            params[key] = value
        docid = self.db.docs.insert(params)
        notify_new_document(docid)
        return docid