Skip to content

Commit 00a7759

Browse files
committed
feat: Deactivate feed on 410 Gone
When a feed returns a 410 Gone status, it is now marked as inactive. If the `--save-config` option is used, this change is persisted to the configuration file. Add also test for deactivating feed on 410 Gone. This commit adds a test case to verify that a feed is deactivated and the configuration is updated when a 410 Gone status is received and the `--save-config` option is used. This addresses the TODO in `rss2email/feed.py` to save the inactive status of a feed.
1 parent 216b778 commit 00a7759

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

rss2email/feed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ def _check_for_errors(self, parsed, save_config=False):
431431
_LOG.warning('deactivate {} because {} is gone'.format(
432432
self.name, self.url))
433433
self.active = False
434-
# TODO: `active` is not saved -- add config option to call feeds.save_config() in run command
434+
if save_config:
435+
self.save_to_config()
435436
return
436437
elif status >= 400:
437438
raise _error.HTTPError(status=status, feed=self)

test/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,25 +435,25 @@ def test_cache_control(self):
435435

436436
queue.put("stop")
437437

438-
def test_redirect(self):
439-
"Saves feed URL on redirect"
438+
def test_deactivate_on_410(self):
439+
"Deactivates feed on 410 Gone"
440440
cfg = """[DEFAULT]
441441
442442

443443
queue = multiprocessing.Queue()
444-
webserver_proc = multiprocessing.Process(target=webserver_for_test_redirect, args=(queue, 301))
444+
webserver_proc = multiprocessing.Process(target=webserver_for_test_redirect, args=(queue, 410))
445445
webserver_proc.start()
446446
port = queue.get()
447447

448448
with ExecContext(cfg) as ctx:
449-
ctx.call("add", 'test', 'http://127.0.0.1:{port}/redirect'.format(port = port))
449+
ctx.call("add", 'test', 'http://127.0.0.1:{port}/gone'.format(port = port))
450450

451451
queue.put("next")
452452
ctx.call("run", "--no-send", "--save-config")
453453

454454
with open(ctx.cfg_path, 'r') as f:
455455
config = f.read()
456-
self.assertIn("url = http://127.0.0.1:{port}/disqus/feed.rss".format(port=port), config)
456+
self.assertIn("active = False", config)
457457

458458
queue.put("stop")
459459

0 commit comments

Comments
 (0)