-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from elliot-100/refine_get_public
Refine `get_public_Info()`
- Loading branch information
Showing
2 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Tests for functions.""" | ||
|
||
from bs4 import BeautifulSoup | ||
|
||
from britishcycling_clubs import ( | ||
_get_club_name_from_profile, | ||
_get_total_members_from_profile, | ||
) | ||
|
||
# Partial extract from actual page | ||
PROFILE_PAGE_EXTRACT = """ | ||
<html> | ||
<h1 class="article__header__title-body__text">My Cycling Club</h1> | ||
<div class="tabs__content" id="about"> | ||
<h2>Club Information</h2> | ||
<div class="grid-tablet-wrap grid-tablet-wide-wrap grid-desktop-wrap"> | ||
<div class="grid-tablet-col-full grid-tablet-wide-col-1-2 grid-desktop-col-1-2"> | ||
<p> | ||
<b>Club type:</b> Club Commercial<br/> | ||
<b>Affiliated: </b>31/12/2023<br/> | ||
<b>Affilation status:</b> Active </p> | ||
<p><b>Total club members:</b> 42<br/></p> | ||
</div> | ||
</html> | ||
""" | ||
|
||
|
||
def test__get_club_name_from_profile__happy_path() -> None: | ||
"""Test that club name is returned from 'profile' soup.""" | ||
profile_soup = BeautifulSoup(PROFILE_PAGE_EXTRACT) | ||
assert _get_club_name_from_profile(profile_soup) == "My Cycling Club" | ||
|
||
|
||
def test__get_total_members_from_profile__happy_path() -> None: | ||
"""Test that total members count is returned from 'profile' soup.""" | ||
profile_soup = BeautifulSoup(PROFILE_PAGE_EXTRACT) | ||
assert _get_total_members_from_profile(profile_soup) == 42 |