Skip to content

Commit

Permalink
Move non-happy doctests to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhed committed Dec 20, 2023
1 parent b368df5 commit ad8a701
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/mijnbib/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ def parse(self) -> list[Account]:
[Account(library_name='Dijk92', user='Johny', id='374047', loans_count=0, loans_url='https://example.com/mijn-bibliotheek/lidmaatschappen/374047/uitleningen',
reservations_count=5, reservations_url='https://example.com/mijn-bibliotheek/lidmaatschappen/384767/reservaties',
open_amounts=0, open_amounts_url='')]
>>> AccountsListPageParser("","https://example.com").parse()
[]
"""
accounts = []
soup = BeautifulSoup(self._html, "html.parser")
Expand Down Expand Up @@ -432,8 +430,6 @@ def parse(self) -> list[Reservation]:
[Reservation(title='Vastberaden!', type='', url='https://city.bibliotheek.be/resolver.ashx?extid=%7Cwise-oostvlaanderen%7C12345',
author='John Doe', location='MyCity', available=False, available_till=None,
request_on=datetime.date(2023, 11, 25), valid_till=datetime.date(2024, 11, 24))]
>>> ReservationsPageParser("").parse() # doctest: +NORMALIZE_WHITESPACE
[]
"""
holds = []
soup = BeautifulSoup(self._html, "html.parser")
Expand Down Expand Up @@ -587,8 +583,6 @@ def _parse_extend_response_status_blob(cls, html_string: str) -> dict:
{'likely_success': True, 'count': 2, 'details':
[{'title': 'Vastberaden!', 'until': datetime.date(2024, 1, 13)},
{'title': 'Iemand moet het doen', 'until': datetime.date(2024, 1, 13)}]}
>>> ExtendResponsePageParser._parse_extend_response_status_blob("")
{'likely_success': False, 'count': 0, 'details': []}
"""
# NOTE: Unclear when & what response when no success (500 server crash on most tests with
# different IDs and combinations)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class TestAccountsListPageParser:
def test_parse_accounts_list_page(self):
# Happy flow test --> see doctest
assert AccountsListPageParser("", "").parse() == []
assert AccountsListPageParser("", "https://example.com").parse() == []

def test_parse_item_count_from_li(self):
assert AccountsListPageParser._parse_item_count_from_li("", "") is None
Expand Down Expand Up @@ -61,6 +61,10 @@ def clean_whitespace(s: str) -> str:
)._extract_html_from_response_script_tag()
assert clean_whitespace(actual_result) == clean_whitespace(expected_result)

def test_parse_extend_response_status_blob__empty_case(self):
actual_result = ExtendResponsePageParser._parse_extend_response_status_blob("")
assert actual_result == {"likely_success": False, "count": 0, "details": []}

def test_parse_extend_response_status_blob__success_case(self):
html_string = """
<div data-drupal-messages>
Expand Down

0 comments on commit ad8a701

Please sign in to comment.