Skip to content

Commit

Permalink
Reformat with black
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanglin-Tao committed May 13, 2024
1 parent 4bdf2e7 commit 2334d0e
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions tests/test_crawl_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@


def test_get_tasks_existing_token_valid():
with patch("os.path.exists", return_value=True), patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred, patch("googleapiclient.discovery.build") as mock_build:
with (
patch("os.path.exists", return_value=True),
patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred,
patch("googleapiclient.discovery.build") as mock_build,
):
mock_cred.return_value.valid = True
mock_cred.return_value.universe_domain = "googleapis.com"

Expand All @@ -51,12 +55,14 @@ def test_get_tasks_existing_token_valid():


def test_get_tasks_existing_token_expired():
with patch("os.path.exists", return_value=True), patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred, patch("google.auth.transport.requests.Request"), patch(
"googleapiclient.discovery.build"
) as mock_build, patch(
"builtins.open", mock_open()
with (
patch("os.path.exists", return_value=True),
patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred,
patch("google.auth.transport.requests.Request"),
patch("googleapiclient.discovery.build") as mock_build,
patch("builtins.open", mock_open()),
):
# Setup mock credentials
mock_cred.return_value.valid = False
Expand All @@ -71,9 +77,9 @@ def refresh(request):

# Setup Google API client mock
mock_service = mock_build.return_value
mock_tasklists = (
mock_service.tasklists().list().execute.return_value
) = MOCK_TASKLISTS
mock_tasklists = mock_service.tasklists().list().execute.return_value = (
MOCK_TASKLISTS
)
mock_tasks = mock_service.tasks().list().execute.return_value = MOCK_TASKS

# Execute function
Expand All @@ -85,9 +91,13 @@ def refresh(request):


def test_get_tasks_no_tasklists():
with patch("os.path.exists", return_value=True), patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred, patch("googleapiclient.discovery.build") as mock_build:
with (
patch("os.path.exists", return_value=True),
patch(
"google.oauth2.credentials.Credentials.from_authorized_user_file"
) as mock_cred,
patch("googleapiclient.discovery.build") as mock_build,
):
# Setup mock credentials
mock_cred.return_value.valid = True

Expand Down

0 comments on commit 2334d0e

Please sign in to comment.