genrss/tests/test_enclosure.py

24 lines
692 B
Python
Raw Normal View History

2019-07-26 19:14:19 +03:00
import pytest
from genrss import Enclosure
2019-08-21 21:34:46 +03:00
def test_init_enclosure_fails():
2019-07-26 19:14:19 +03:00
with pytest.raises(TypeError):
Enclosure()
assert False
2019-08-21 21:34:46 +03:00
def test_init_enclosure(enclosure_tuple):
2019-07-26 19:14:19 +03:00
url, size, type = enclosure_tuple
enclosure = Enclosure(url, size, type)
assert enclosure.url == url
assert enclosure.size == (size or 0)
assert enclosure.type == (type or 'image/jpeg')
2019-08-21 21:34:46 +03:00
def test_init_enclosure_from_dict(enclosure_dict):
2019-07-26 19:14:19 +03:00
enclosure = Enclosure.from_dict(enclosure_dict)
assert enclosure.url == enclosure_dict.get('url')
assert enclosure.size == enclosure_dict.get('size', 0)
assert enclosure.type == enclosure_dict.get('type', 'image/jpeg')