genrss/tests/test_enclosure.py

23 lines
692 B
Python

import pytest
from genrss import Enclosure
def test_init_enclosure_fails():
with pytest.raises(TypeError):
Enclosure()
assert False
def test_init_enclosure(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_enclosure_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')