def test_all(self, wildcard): docs = [ {"key": "/foo", "type": {"key": "/type/object"}, "title": "foo"}, {"key": "/bar", "type": {"key": "/type/object"}, "title": "bar"}, ] timestamp = datetime.datetime(2010, 01, 02, 03, 04, 05) self._save(docs, comment="testing recentchanges", timestamp=timestamp) engine = RecentChanges(db) changes = engine.recentchanges(limit=1) assert changes == [ { "id": wildcard, "kind": "test_save", "timestamp": timestamp.isoformat(), "comment": "testing recentchanges", "ip": "1.2.3.4", "author": None, "changes": [{"key": "/foo", "revision": 1}, {"key": "/bar", "revision": 1}], "data": {}, } ] engine.get_change(changes[0]["id"]) == { "id": wildcard, "kind": "test_save", "timestamp": timestamp.isoformat(), "comment": "testing recentchanges", "ip": "1.2.3.4", "author": None, "changes": [{"key": "/foo", "revision": 1}, {"key": "/bar", "revision": 1}], "data": {}, }
def recentchanges(self, query): """Returns the list of changes matching the given query. Sample Queries: {"limit": 10, "offset": 100} {"limit": 10, "offset": 100, "key": "/authors/OL1A"} {"limit": 10, "offset": 100, "author": "/people/foo"} """ engine = RecentChanges(self.db) limit = query.pop("limit", 1000) offset = query.pop("offset", 0) keys = "key", "author", "ip", "kind", "bot", "begin_date", "end_date", "data" kwargs = dict((k, query[k]) for k in keys if k in query) return engine.recentchanges(limit=limit, offset=offset, **kwargs)
def test_all(self, wildcard): docs = [{ "key": "/foo", "type": { "key": "/type/object" }, "title": "foo" }, { "key": "/bar", "type": { "key": "/type/object" }, "title": "bar" }] timestamp = datetime.datetime(2010, 01, 02, 03, 04, 05) self._save(docs, comment="testing recentchanges", timestamp=timestamp) engine = RecentChanges(db) changes = engine.recentchanges(limit=1) assert changes == [{ "id": wildcard, "kind": "test_save", "timestamp": timestamp.isoformat(), "comment": "testing recentchanges", "ip": "1.2.3.4", "author": None, "changes": [ { "key": "/foo", "revision": 1 }, { "key": "/bar", "revision": 1 }, ], "data": {} }] engine.get_change(changes[0]['id']) == { "id": wildcard, "kind": "test_save", "timestamp": timestamp.isoformat(), "comment": "testing recentchanges", "ip": "1.2.3.4", "author": None, "changes": [ { "key": "/foo", "revision": 1 }, { "key": "/bar", "revision": 1 }, ], "data": {} }