def apply_timestamp(stage, feed_id, timestamp): with stage: feed = stage.feeds[feed_id] feed.entries[0].read = Mark(marked=True, updated_at=timestamp) assert feed.entries[0].read.updated_at == timestamp written = read(Feed, write(feed, as_bytes=True)) assert written.entries[0].read.updated_at == timestamp, repr( (written.entries[0].read.updated_at, timestamp)) stage.feeds[feed_id] = feed
def fx_mark_false(): return Mark(marked=False, updated_at=datetime.datetime(2013, 11, 6, 14, 36, 0, tzinfo=utc))
def fx_filtering_entries(fx_test_stage): authors = [Person(name='vio')] now = datetime.datetime(2013, 10, 30, 20, 55, 30, tzinfo=utc) feed = Feed(id='http://feedone.com/feed/atom/', authors=authors, title=Text(value='Feed One'), updated_at=now) for i in range(10): feed.entries.append( Entry(id='http://feedone.com/feed/atom/' + str(i) + '/', authors=authors, title=Text(value=str(i + 1)), updated_at=now + datetime.timedelta(days=1) * i) ) for i in range(5): feed.entries[i].read = Mark(marked=True, updated_at=now) for i in range(3, 7): feed.entries[i].starred = Mark(marked=True, updated_at=now) with fx_test_stage as stage: stage.feeds[get_hash('http://feedone.com/feed/atom/')] = feed stage.subscriptions = read(SubscriptionList, opml_for_filtering)
def test_feed_mark_read(fx_feed): assert fx_feed.entries[0].read == Mark(marked=True, updated_at=datetime.datetime( 2013, 11, 6, 14, 36, 0, tzinfo=utc)) assert fx_feed.entries[1].read is None
def test_merge_marks(fx_stages, fx_feed): stage_a, stage_b = fx_stages with stage_a: stage_a.feeds['test'] = fx_feed feed_a = stage_a.feeds['test'] with stage_b: feed_b = stage_b.feeds['test'] with stage_b: feed_b.entries[0].read = Mark(marked=True, updated_at=timestamp(1)) stage_b.feeds['test'] = feed_b with stage_a: feed_a.entries[0].read = Mark(marked=True, updated_at=timestamp(2)) stage_a.feeds['test'] = feed_a with stage_b: feed_b.entries[0].read = Mark(marked=False, updated_at=timestamp(3)) stage_b.feeds['test'] = feed_b with stage_b: feed_b.entries[0].starred = Mark(marked=True, updated_at=timestamp(4)) stage_b.feeds['test'] = feed_b with stage_b: feed_b.entries[0].starred = Mark(marked=False, updated_at=timestamp(5)) stage_b.feeds['test'] = feed_b with stage_a: feed_a.entries[0].starred = Mark(marked=True, updated_at=timestamp(6)) stage_a.feeds['test'] = feed_a with stage_b: stage_b.feeds['test'] = feed_b with stage_a: print(repr(stage_a.feeds['test'])) with stage_a: entry_a = stage_a.feeds['test'].entries[0] with stage_b: entry_b = stage_b.feeds['test'].entries[0] assert not entry_a.read assert not entry_b.read assert entry_a.starred assert entry_b.starred assert (entry_a.read.updated_at == entry_b.read.updated_at == timestamp(3)) assert (entry_a.starred.updated_at == entry_b.starred.updated_at == timestamp(6))