genrss/tests/test_enclosure.py

24 lines
662 B
Python
Raw Permalink Normal View History

2019-07-26 19:14:19 +03:00
import pytest
from genrss import Enclosure
def test_init_fails():
with pytest.raises(TypeError):
Enclosure()
assert False
def test_init(enclosure_tuple):
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')
def test_init_from_dict(enclosure_dict):
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')