Skip to content

Commit

Permalink
test suite: API tests for obtaining item counts from user page
Browse files Browse the repository at this point in the history
  • Loading branch information
Noiredd committed May 10, 2020
1 parent e5098a3 commit 7ede8e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7ede8e0

Please sign in to comment.