Skip to content

Commit

Permalink
test_reader_filter.py::test_entries should use the same reader (saves…
Browse files Browse the repository at this point in the history
… .8s). #328
  • Loading branch information
lemon24 committed Dec 8, 2023
1 parent 87bbf24 commit aa08de3
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions tests/test_reader_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,32 @@ def test_entries_by_entry_tags(reader, get_entries, tags, expected):
}


@pytest.fixture(scope='module')
def reader_entries():
with make_reader(':memory:') as reader:
reader._parser = parser = Parser()

one = parser.feed(1, datetime(2010, 1, 1))
one_one = parser.entry(1, 1, datetime(2010, 1, 1))
one_two = parser.entry(1, 2, datetime(2010, 2, 1)) # read
one_three = parser.entry(1, 3, datetime(2010, 2, 1)) # important
one_four = parser.entry(
1, 4, datetime(2010, 2, 1), enclosures=[Enclosure('http://e2')]
)
two = parser.feed(2, datetime(2010, 1, 1))
two_one = parser.entry(2, 1, datetime(2010, 2, 1))

reader.add_feed(one.url)
reader.add_feed(two.url)
reader.update_feeds()
reader.update_search()

reader.mark_entry_as_read((one.url, one_two.id))
reader.mark_entry_as_important((one.url, one_three.id))

yield reader


@pytest.mark.parametrize(
'kwargs, expected',
[
Expand Down Expand Up @@ -175,28 +201,8 @@ def test_entries_by_entry_tags(reader, get_entries, tags, expected):
(dict(entry=('inexistent', 'also-inexistent')), set()),
],
)
@rename_argument('reader', 'reader_entries')
def test_entries(reader, get_entries, kwargs, expected):
parser = Parser()
reader._parser = parser

one = parser.feed(1, datetime(2010, 1, 1))
one_one = parser.entry(1, 1, datetime(2010, 1, 1))
one_two = parser.entry(1, 2, datetime(2010, 2, 1)) # read
one_three = parser.entry(1, 3, datetime(2010, 2, 1)) # important
one_four = parser.entry(
1, 4, datetime(2010, 2, 1), enclosures=[Enclosure('http://e2')]
)
two = parser.feed(2, datetime(2010, 1, 1))
two_one = parser.entry(2, 1, datetime(2010, 2, 1))

reader.add_feed(one.url)
reader.add_feed(two.url)
reader.update_feeds()
get_entries.after_update(reader)

reader.mark_entry_as_read((one.url, one_two.id))
reader.mark_entry_as_important((one.url, one_three.id))

assert {eval(e.id) for e in get_entries(reader, **kwargs)} == expected

# TODO: how do we test the combinations between arguments?
Expand Down

0 comments on commit aa08de3

Please sign in to comment.