-
Notifications
You must be signed in to change notification settings - Fork 10
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
Get endpoint uri test #42
Changes from 3 commits
63ea2e5
8f9a3eb
ccd9fd1
03ad784
df54f72
9e4443e
08cf401
6f6974c
d3bd146
8d3970f
b9fdcf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from unittest.mock import * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here d3bd146 |
||
import pytest | ||
from giza.schemas.endpoints import Endpoint, EndpointsList | ||
from giza_actions.utils import get_endpoint_uri | ||
|
||
endpoint_data = Endpoint(id=999, size="S", is_active=True, model_id=999, version_id=999, uri="testing.uri") | ||
endpoint_list = EndpointsList(root=[endpoint_data]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To improve readability a bit we could add this inside the test and add it to the mock: @patch("giza.client.EndpointsClient.list")
def test_get_endpoint_uri_successful(mock_get):
"""
Tests successful retrieval of the deployment URI for a model and version.
"""
endpoint_data = Endpoint(id=999, size="S", is_active=True, model_id=999, version_id=999, uri="testing.uri")
endpoint_list = EndpointsList(root=[endpoint_data])
mock_get.return_value = endpoint_list
uri = get_endpoint_uri(model_id=788, version_id=23)
assert uri is "testing.uri"
mock_get.assert_called_once() This way data that its only for a test its contained inside and not for the whole script. Make sure to change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already done this too, it is the df54f72 commit |
||
@patch("giza.client.EndpointsClient.list", return_value=endpoint_list) | ||
def test_get_endpoint_uri_successful(mock_get): | ||
""" | ||
Tests successful retrieval of the deployment URI for a model and version. | ||
""" | ||
uri = get_endpoint_uri(model_id=788, version_id=23) | ||
assert uri is "testing.uri" | ||
mock_get.assert_called_once() | ||
|
||
endpoint_list = EndpointsList(root=[]) | ||
@patch("giza.client.EndpointsClient.list", return_value=endpoint_list) | ||
def test_get_endpoint_uri_not_found(mock_get): | ||
""" | ||
Tests the case where no active deployment is found for the model and version. | ||
""" | ||
uri = get_endpoint_uri(model_id=516, version_id=19) | ||
assert uri is None | ||
mock_get.assert_called_once() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is missing formatting, this should have been handled by
pre-commit
, make sure it is installed and runpre-commit run --files tests/test_utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done this, you can see it at 08cf401 commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running pre-commit locally yields changes:
Run
pre-commit run --files tests/test_utils.py
and fix the formating and linting issuesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now I get it right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.