-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_parsing.py
51 lines (40 loc) · 1.21 KB
/
test_parsing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import logging
from typing import Type
import pytest
from rss_parser import AtomParser, BaseParser, RSSParser
logger = logging.getLogger(__name__)
class DataHelper:
@staticmethod
def compare_parsing(sample_and_result, parser: Type[BaseParser]):
sample, result = sample_and_result
rss = parser.parse(sample)
assert rss
parsed = rss.dict()
assert parsed == result
@pytest.mark.usefixtures("sample_and_result")
class TestRSS:
@pytest.mark.parametrize(
"sample_and_result",
[
["rss_2"],
["rss_2_no_category_attr"],
["apology_line"],
["rss_2_with_1_item"],
["github-49"],
],
indirect=True,
)
def test_parses_all_rss_samples(self, sample_and_result):
DataHelper.compare_parsing(sample_and_result, parser=RSSParser)
@pytest.mark.usefixtures("sample_and_result")
class TestAtom:
@pytest.mark.parametrize(
"sample_and_result",
[
["atom"],
["generic_atom_feed"],
],
indirect=True,
)
def test_parses_all_atom_samples(self, sample_and_result):
DataHelper.compare_parsing(sample_and_result, parser=AtomParser)