From f4861a872cf92b51ecfe586b6f6acba32c11db25 Mon Sep 17 00:00:00 2001 From: lemon24 Date: Sat, 23 Jul 2022 16:19:29 +0300 Subject: [PATCH] Remove mark_as_read config tag name migration. For #268. --- CHANGES.rst | 11 ++++++++++- src/reader/plugins/mark_as_read.py | 19 ------------------- tests/test_plugins_mark_as_read.py | 23 ----------------------- 3 files changed, 10 insertions(+), 43 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 14e0cb79..0fcc920f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,6 +18,8 @@ Unreleased * Remove old database migrations. + Remove :mod:`~reader.plugins.mark_as_read` config tag name migration. + If you are upgrading from *reader* 2.10 or newer, no action is required. .. _removed migrations 3.0: @@ -34,8 +36,15 @@ Unreleased python - db.sqlite << EOF import sys from reader import make_reader - make_reader(sys.argv[1]) + from reader.plugins.mark_as_read import _migrate_pre_2_7_metadata as migrate_mark_as_read + + reader = make_reader(sys.argv[1]) + + for feed in reader.get_feeds(): + migrate_mark_as_read(reader, feed) + print("OK") + EOF * Remove code that issued deprecation warnings in versions 2.* (:issue:`268`): diff --git a/src/reader/plugins/mark_as_read.py b/src/reader/plugins/mark_as_read.py index ddac238e..cedc5324 100644 --- a/src/reader/plugins/mark_as_read.py +++ b/src/reader/plugins/mark_as_read.py @@ -80,24 +80,5 @@ def _mark_as_read(reader, entry, status): return -_OLD_CONFIG_TAG = 'mark_as_read' - - -def _migrate_pre_2_7_metadata(reader, feed): - old_key = reader.make_reader_reserved_name(_OLD_CONFIG_TAG) - old_value = reader.get_tag(feed, old_key, None) - if not old_value: - return - - key = reader.make_reader_reserved_name(_CONFIG_TAG) - value = reader.get_tag(feed, key, None) - if value: # pragma: no cover - return - - reader.set_tag(feed, key, old_value) - reader.delete_tag(feed, old_key) - - def init_reader(reader): - reader.before_feed_update_hooks.append(_migrate_pre_2_7_metadata) reader.after_entry_update_hooks.append(_mark_as_read) diff --git a/tests/test_plugins_mark_as_read.py b/tests/test_plugins_mark_as_read.py index c4b89fbf..82dba853 100644 --- a/tests/test_plugins_mark_as_read.py +++ b/tests/test_plugins_mark_as_read.py @@ -74,26 +74,3 @@ def test_regex_mark_as_read_bad_metadata(make_reader, value): reader.update_feeds() assert [e.read for e in reader.get_entries()] == [False] - - -@pytest.mark.parametrize('with_entry', [False, True]) -def test_regex_mark_as_read_pre_2_7_metadata(make_reader, with_entry): - reader = make_reader(':memory:', plugins=['reader.mark_as_read']) - - parser = Parser() - reader._parser = parser - - one = parser.feed(1, datetime(2010, 1, 1)) - if with_entry: - parser.entry(1, 1, datetime(2010, 1, 1), title='match old') - - reader.add_feed(one) - reader.set_tag(one, '.reader.mark_as_read', {'title': ['^match']}) - - reader.update_feeds() - - assert all(e.read for e in reader.get_entries()) - - tags = dict(reader.get_tags(one)) - assert '.reader.mark_as_read' not in tags - assert tags['.reader.mark-as-read'] == {'title': ['^match']}