From 7ede8e0efd40846b2ff307a95d775a87333e215d Mon Sep 17 00:00:00 2001 From: Noiredd Date: Sun, 10 May 2020 14:16:02 +0200 Subject: [PATCH] test suite: API tests for obtaining item counts from user page --- test/README.md | 3 ++- test/test_api.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index f0931d2..42da445 100644 --- a/test/README.md +++ b/test/README.md @@ -16,7 +16,8 @@ instead these cached files are used as data source. Test class `TestAPIBasics` encapsulates tests of the most fundamental functionalities: * logging in to Filmweb.pl, -* fetching raw HTML data. +* fetching raw HTML data, +* obtaining the item count for each particular item type. However, the most important one are the `fetch_save` tests, which not only grab online data, but also **store it locally** (in `test/assets`), to simplify performing other tests. diff --git a/test/test_api.py b/test/test_api.py index a9a1e06..a6729f1 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -117,6 +117,24 @@ def test_30_fetch_save_games(self): html.write(text) self.assertIn('games_{}.html'.format(page_num), os.listdir('assets')) + def __test_count_body(self, itemtype:str): + """Performs a single test of item count retrieval.""" + item_count, items_per_page = self.api.getNumOf(itemtype) + self.assertGreater(item_count, 0) + self.assertGreaterEqual(item_count, items_per_page) + + def test_40_get_num_of_movies(self): + """Attempt to retrieve the item count of type 'Movie'.""" + self.__test_count_body('Movie') + + def test_41_get_num_of_series(self): + """Attempt to retrieve the item count of type 'Series'.""" + self.__test_count_body('Series') + + def test_42_get_num_of_games(self): + """Attempt to retrieve the item count of type 'Game'.""" + self.__test_count_body('Game') + class TestAPIParsing(unittest.TestCase): """Test API parsing functionalities.