def test_delete(ctx): from melkman.db import RemoteFeed, NewsItem, NewsItemRef feed_url = 'http://example.org/feeds/1' dummy_feed = random_atom_feed(feed_url, 25) items = melk_ids_in(dummy_feed, feed_url) rf = RemoteFeed.create_from_url(feed_url, ctx) rf.update_from_feed(dummy_feed, 'test') rf.save() bucket_id = rf.id ref_ids = [] assert bucket_id in ctx.db for iid in items: assert iid in rf.entries ref_id = NewsItemRef.dbid(bucket_id, iid) ref_ids.append(ref_id) assert ref_id in ctx.db # a news item was created too... assert iid in ctx.db # now destroy! rf.delete() assert not bucket_id in ctx.db for ref_id in ref_ids: assert not ref_id in ctx.db for iid in items: assert not iid in ctx.db
def test_bucket_delete(ctx): from melkman.db import NewsBucket, NewsItemRef bucket = NewsBucket.create(ctx) items = [random_id() for i in range(1000)] for iid in items: bucket.add_news_item(iid) bucket.save() bucket_id = bucket.id ref_ids = [] assert bucket_id in ctx.db for iid in items: assert iid in bucket.entries ref_id = NewsItemRef.dbid(bucket.id, iid) ref_ids.append(ref_id) assert ref_id in ctx.db # now destroy! bucket.delete() assert not bucket_id in ctx.db for ref_id in ref_ids: assert not ref_id in ctx.db