From 02ea90ec6a8239670e5221429d46656c37bf9a2d Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Sun, 8 Aug 2021 23:28:40 +0200 Subject: [PATCH] Test sporza html scraper --- functions/scrapers/sporza.py | 1 - tests/functions/scrapers/__init__.py | 0 tests/functions/scrapers/test_sporza.py | 13 +++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/functions/scrapers/__init__.py create mode 100644 tests/functions/scrapers/test_sporza.py diff --git a/functions/scrapers/sporza.py b/functions/scrapers/sporza.py index 22c6cf2..69a8633 100644 --- a/functions/scrapers/sporza.py +++ b/functions/scrapers/sporza.py @@ -1,7 +1,6 @@ from bs4 import BeautifulSoup import re from requests import get -from urllib.parse import urlencode def getMatchweek(): diff --git a/tests/functions/scrapers/__init__.py b/tests/functions/scrapers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/functions/scrapers/test_sporza.py b/tests/functions/scrapers/test_sporza.py new file mode 100644 index 0000000..744341f --- /dev/null +++ b/tests/functions/scrapers/test_sporza.py @@ -0,0 +1,13 @@ +from functions.scrapers import sporza +import unittest + + +class TestSporzaScraper(unittest.TestCase): + def test_find_matchweek(self): + """ + This tests if the structure of the HTML is still what we expect it to be, + as Sporza changes it from time to time. + """ + # This will throw an error if the argument was not a proper integer + week = int(sporza.getMatchweek()) + self.assertGreater(week, 0)