コード例 #1
0
    def test_delete(self):
        self.assertEqual(ItemRedirect.query.count(), 0)

        item = Item.create()
        redirect = ItemRedirect(old_id=42, new_id=item.id)
        db.session.add(redirect)
        db.session.flush()
        self.assertEqual(ItemRedirect.query.count(), 1)

        redirect.delete()
        self.assertEqual(ItemRedirect.query.count(), 0)
コード例 #2
0
    def test_delete(self):
        redirects = ItemRedirect.query.all()
        assert len(redirects) == 0

        item = Item.create()
        redirect = ItemRedirect(old_id=42, new_id=item.id)
        db.session.add(redirect)
        db.session.flush()

        redirects = ItemRedirect.query.all()
        assert len(redirects) == 1
        assert redirects[0] == redirect

        redirect.delete()

        redirects = ItemRedirect.query.all()
        assert len(redirects) == 0