Exemplo n.º 1
0
    def test_get_content_diff(self):
        item = self.imw[self.item_name]
        rev1 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain;charset=utf-8'),
                                   BytesIO(b'x'), trusted=True, return_rev=True)
        notification = Notification(app, self.fqname, ACTION_SAVE, None, None, rev1.data, rev1.meta)
        assert notification.get_content_diff() == ["+ x"]
        rev1.data.seek(0, 0)

        rev2 = item.store_revision(dict(name=[self.item_name, ], contenttype='text/plain;charset=utf-8'),
                                   BytesIO(b'xx'), trusted=True, return_rev=True)
        notification = Notification(app, self.fqname, ACTION_SAVE, rev1.data, rev1.meta, rev2.data, rev2.meta,)
        assert notification.get_content_diff() == ['- x', '+ xx']
        rev2.data.seek(0, 0)

        notification = Notification(app, self.fqname, ACTION_TRASH, rev2.data, rev2.meta, None, None)
        assert notification.get_content_diff() == ['- xx']
        rev2.data.seek(0, 0)

        item = Item.create(self.item_name)
        notification = Notification(app, self.fqname, DESTROY_REV, rev2.data, rev2.meta, None, None)
        assert notification.get_content_diff() == ['- xx']
        rev2.data.seek(0, 0)

        item = Item.create(self.item_name)
        notification = Notification(app, self.fqname, DESTROY_ALL, rev2.data, rev2.meta, None, None)
        assert notification.get_content_diff() == ['- xx']
Exemplo n.º 2
0
    def test_get_content_diff(self):
        item = self.imw[self.item_name]
        rev1 = item.store_revision(dict(name=[
            self.item_name,
        ],
                                        contenttype='text/plain'),
                                   BytesIO(b'x'),
                                   trusted=True,
                                   return_rev=True)
        notification = Notification(app,
                                    self.fqname, [rev1],
                                    action=ACTION_SAVE)
        assert notification.get_content_diff() == ["+ x"]
        rev1.data.seek(0, 0)

        rev2 = item.store_revision(dict(name=[
            self.item_name,
        ],
                                        contenttype='text/plain'),
                                   BytesIO(b'xx'),
                                   trusted=True,
                                   return_rev=True)
        notification = Notification(app,
                                    self.fqname, [rev2, rev1],
                                    action=ACTION_SAVE)
        assert notification.get_content_diff() == ['- x', '+ xx']
        rev2.data.seek(0, 0)

        notification = Notification(app,
                                    self.fqname, [rev2, rev1],
                                    action=ACTION_TRASH)
        assert notification.get_content_diff() == ['- xx']
        rev2.data.seek(0, 0)

        item = Item.create(self.item_name)
        notification = Notification(app,
                                    self.fqname, [],
                                    content=item.rev.data,
                                    meta=rev2.meta,
                                    action=DESTROY_REV)
        assert notification.get_content_diff() == ['- xx']
        rev2.data.seek(0, 0)

        item = Item.create(self.item_name)
        notification = Notification(app,
                                    self.fqname, [],
                                    content=item.rev.data,
                                    meta=rev2.meta,
                                    action=DESTROY_ALL)
        assert notification.get_content_diff() == ['- xx']