Skip to content

Commit

Permalink
Tighten up utils.get_user_agent and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Dec 22, 2022
1 parent 51d183b commit f24ab7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion newshomepages/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ def get_extract_df(name: str, **kwargs) -> pd.DataFrame:


def get_user_agent() -> str:
"""Return a user agent string ready to pass to a browser."""
"""Provide a user-agent string.
Returns a string ready to use as a header in web request.
"""
return "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"


Expand Down
5 changes: 5 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def test_get_local_time():
assert utils.get_local_time(bbc).tzname() == "GMT"


def test_get_user_agent():
"""Test get_user_agent."""
assert utils.get_user_agent()


def test_sites():
"""Test sites utils."""
# Read in the list
Expand Down

0 comments on commit f24ab7d

Please sign in to comment.