Skip to content

Commit

Permalink
Rename fixture call_update_method to update_feed.
Browse files Browse the repository at this point in the history
For #218.
  • Loading branch information
lemon24 committed Aug 3, 2023
1 parent 555b860 commit 05aefc1
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 89 deletions.
47 changes: 10 additions & 37 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,17 @@ def storage():
yield storage


# TODO: move to reader_methods
# TODO: s/call_update_method/update_feed/
def call_update_feeds(reader, _):
reader.update_feeds()


def call_update_feeds_workers(reader, _):
reader.update_feeds(workers=2)


def call_update_feeds_iter(reader, _):
for _ in reader.update_feeds_iter():
pass


def call_update_feeds_iter_workers(reader, _):
for _ in reader.update_feeds_iter(workers=2):
pass


def call_update_feed(reader, url):
reader.update_feed(url)
def slow(*args, **kwargs):
return pytest.param(*args, **kwargs, marks=pytest.mark.slow)


@pytest.fixture(
params=[
call_update_feeds,
pytest.param(call_update_feeds_workers, marks=pytest.mark.slow),
call_update_feeds_iter,
pytest.param(call_update_feeds_iter_workers, marks=pytest.mark.slow),
call_update_feed,
m if 'workers' not in m.__name__ else slow(m)
for m in reader_methods.update_feed_methods
]
)
def call_update_method(request):
def update_feed(request):
return request.param


Expand Down Expand Up @@ -180,9 +157,9 @@ def data_dir(tests_dir):
Storage.chunk_size,
# rough result size (order of magnitude)
1,
pytest.param(2, marks=pytest.mark.slow),
slow(2),
# unchunked query, likely to be ok
pytest.param(0, marks=pytest.mark.slow),
slow(0),
]
)
def chunk_size(request):
Expand All @@ -196,15 +173,11 @@ def get_entries(request):

@pytest.fixture(
params=[
pytest.param(reader_methods.get_entries, marks=pytest.mark.slow),
slow(reader_methods.get_entries),
reader_methods.get_entries_recent,
pytest.param(
reader_methods.get_entries_recent_paginated, marks=pytest.mark.slow
),
slow(reader_methods.get_entries_recent_paginated),
reader_methods.search_entries_recent,
pytest.param(
reader_methods.search_entries_recent_paginated, marks=pytest.mark.slow
),
slow(reader_methods.search_entries_recent_paginated),
],
)
def get_entries_recent(request):
Expand Down
25 changes: 25 additions & 0 deletions tests/reader_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,28 @@ def search_entry_counts(reader, **kwargs):
search_entries_recent,
search_entries_random,
]


class _update_feed_methods:
def update_feeds(reader, _):
reader.update_feeds()

def update_feeds_workers(reader, _):
reader.update_feeds(workers=2)

def update_feeds_iter(reader, _):
for _ in reader.update_feeds_iter():
pass

def update_feeds_iter_workers(reader, _):
for _ in reader.update_feeds_iter(workers=2):
pass

def update_feed(reader, url):
reader.update_feed(url)


# update_feed(reader, feed) -> None
update_feed_methods = [
v for k, v in _update_feed_methods.__dict__.items() if not k.startswith('_')
]
Loading

0 comments on commit 05aefc1

Please sign in to comment.