Skip to content

Commit

Permalink
Update test_browse_scrape_links.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresCdo committed Apr 20, 2023
1 parent 552e5f4 commit 4983ddb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/unit/test_browse_scrape_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@


class TestScrapeLinks:
"""Tests for the scrape_links function."""
# Tests that the function returns a list of formatted hyperlinks when
# provided with a valid url that returns a webpage with hyperlinks.
def test_valid_url_with_hyperlinks(self):
Expand All @@ -49,6 +50,7 @@ def test_valid_url_with_hyperlinks(self):

# Tests that the function returns correctly formatted hyperlinks when given a valid url.
def test_valid_url(self, mocker):
"""Test that the function returns correctly formatted hyperlinks when given a valid url."""
# Mock the requests.get() function to return a response with sample HTML containing hyperlinks
mock_response = mocker.Mock()
mock_response.status_code = 200
Expand All @@ -65,6 +67,7 @@ def test_valid_url(self, mocker):

# Tests that the function returns "error" when given an invalid url.
def test_invalid_url(self, mocker):
"""Test that the function returns "error" when given an invalid url."""
# Mock the requests.get() function to return an HTTP error response
mock_response = mocker.Mock()
mock_response.status_code = 404
Expand All @@ -78,6 +81,7 @@ def test_invalid_url(self, mocker):

# Tests that the function returns an empty list when the html contains no hyperlinks.
def test_no_hyperlinks(self, mocker):
"""Test that the function returns an empty list when the html contains no hyperlinks."""
# Mock the requests.get() function to return a response with sample HTML containing no hyperlinks
mock_response = mocker.Mock()
mock_response.status_code = 200
Expand All @@ -93,6 +97,7 @@ def test_no_hyperlinks(self, mocker):
# Tests that scrape_links() correctly extracts and formats hyperlinks from
# a sample HTML containing a few hyperlinks.
def test_scrape_links_with_few_hyperlinks(self, mocker):
"""Test that scrape_links() correctly extracts and formats hyperlinks from a sample HTML containing a few hyperlinks."""
# Mock the requests.get() function to return a response with a sample HTML containing hyperlinks
mock_response = mocker.Mock()
mock_response.status_code = 200
Expand Down

0 comments on commit 4983ddb

Please sign in to comment.