Skip to content

Commit

Permalink
fix(RELEASE-1285): add pyxis.patch tests
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Malina <[email protected]>
  • Loading branch information
mmalina committed Nov 25, 2024
1 parent 83fb766 commit 0e121e1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pyxis/test_pyxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,37 @@ def test_post_error(mock_get_session: MagicMock) -> None:
pyxis.post(API_URL, {})


@patch("pyxis.session", None)
@patch("pyxis._get_session")
def test_patch(mock_get_session: MagicMock) -> None:
resp = pyxis.patch(API_URL, {})

assert resp == mock_get_session.return_value.patch.return_value
mock_get_session.assert_called_once_with()


@patch("pyxis.session")
@patch("pyxis._get_session")
def test_patch_existing_session(mock_get_session, mock_session: MagicMock) -> None:
resp = pyxis.patch(API_URL, {})

assert resp == mock_session.patch.return_value
mock_get_session.assert_not_called()


@patch("pyxis.session", None)
@patch("pyxis._get_session")
def test_patch_error(mock_get_session: MagicMock) -> None:
response = Response()
response.status_code = 400
mock_get_session.return_value.patch.return_value.raise_for_status.side_effect = HTTPError(
response=response
)

with pytest.raises(HTTPError):
pyxis.patch(API_URL, {})


@patch("pyxis.post")
def test_graphql_query__success(mock_post: MagicMock):
mock_data = {
Expand Down

0 comments on commit 0e121e1

Please sign in to comment.