Exemplo n.º 1
0
    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": {},
        }
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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": {}
        }
Exemplo n.º 4
0
 def recentchanges(self, **kw):
     return RecentChanges(db).recentchanges(**kw)
Exemplo n.º 5
0
 def changes(**kw):
     return [
         c['comment'] for c in RecentChanges(db).recentchanges(**kw)
     ]
Exemplo n.º 6
0
 def get_change(self, id):
     """Return the info about the requested change.
     """
     engine = RecentChanges(self.db)
     return engine.get_change(id)