solo-auswertung/src/solo_turnier/tests/test_html_parser.py

29 lines
806 B
Python
Raw Normal View History

import pytest
import os
import json
import solo_turnier.html_parser
@pytest.fixture(scope='module', params=["1", '2'])
def dataProviderHtmlParser(request):
variant = request.param
dir = os.path.join(os.path.dirname(__file__), 'html_parser', variant)
htmlFile = os.path.join(dir, 'erg.htm')
jsonFile = os.path.join(dir, 'expected.json')
with open(htmlFile, 'r') as fp:
html = fp.read()
with open(jsonFile, 'r') as fp:
jsonContent = json.load(fp)
return (html, jsonContent)
def test_extractDataFromHtml(dataProviderHtmlParser):
htmlString = dataProviderHtmlParser[0]
expected = dataProviderHtmlParser[1]
parser = solo_turnier.html_parser.HtmlParser()
actualResult = parser.parseString(htmlString)
assert actualResult == expected