tenkan/tests/feedsfile_test.py
2022-01-12 22:00:37 +01:00

43 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
from pathlib import Path
from tenkan.feedsfile import (
add_feed,
del_feed,
get_feed_item,
read,
update_feed,
)
def test_get_feed_item():
feeds = Path('./tests/data/feeds.json')
item = get_feed_item(file=feeds, feed_name='srad-science', item='url')
assert item == 'https://srad.jp/science.rss'
def test_update_hash():
feeds = Path('./tests/data/feeds.json')
update_feed(file=feeds, feed_name='srad-science', hash_last_update='blbl')
item = get_feed_item(
file=feeds, feed_name='srad-science', item='hash_last_update'
)
assert item == 'blbl'
update_feed(file=feeds, feed_name='srad-science', hash_last_update='')
def test_add_feed():
feeds = Path('./tests/data/feeds.json')
add_feed(file=feeds, feed_name='toto', feed_url='tata')
data = read(file=feeds)
assert data['feeds'].get('toto')
del_feed(file=feeds, feed_name='toto')
def test_del_feed():
feeds = Path('./tests/data/feeds.json')
add_feed(file=feeds, feed_name='tutu', feed_url='tata')
del_feed(file=feeds, feed_name='tutu')
data = read(file=feeds)
assert not data['feeds'].get('tutu')