Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new test for get_workspace_uri() method #43

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from unittest import TestCase, mock

import requests
from giza.schemas.workspaces import Workspace

from giza_actions.utils import get_workspace_uri


@mock.patch("giza.client.WorkspaceClient.get")
def test_get_workspace_uri_successful(mock_get):
"""
Tests successful retrieval the URI of the current workspace.
"""
mock_workspace = Workspace(status="test", url="test_url")
mock_get.return_value = mock_workspace
workspace_uri = get_workspace_uri()
assert workspace_uri == "test_url"
mock_get.assert_called_once()


@mock.patch("giza.client.WorkspaceClient.get")
def test_get_workspace_uri_request_exception(mock_get):
"""
Tests RequestException in get_workspace_uri method().
"""
mock_get.side_effect = requests.exceptions.RequestException

TestCase.assertRaises(
TestCase, requests.exceptions.RequestException, get_workspace_uri
)
Loading