Skip to content

Commit

Permalink
fix: Ammend local tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim-Encord committed Dec 3, 2024
1 parent 92ddc23 commit 728f73a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/http/test_timeout_overrides_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def test_request_timeout_settings_correctly_propagated(send: MagicMock, api_clie
# Re-mocking for V2 API
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"results": []}
mock_response.content = json.dumps({"results": []})
mock_response.json.return_value = {"results": [], "next_page_token": None}
mock_response.content = json.dumps({"results": [], "next_page_token": None})
send.side_effect = None
send.return_value = mock_response

Expand Down
8 changes: 5 additions & 3 deletions tests/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def construct_timer(
def test_project_collaborator_timers_empty_page(api_client_get: MagicMock, project: Project):
after_time = parse_datetime("2023-01-01T21:00:00")

api_client_get.return_value = Page[CollaboratorTimer](results=[])
api_client_get.return_value = Page[CollaboratorTimer](results=[], next_page_token=None)

timers = list(project.list_collaborator_timers(after=after_time))

Expand All @@ -48,7 +48,8 @@ def test_project_collaborator_timers_single_page(api_client_get: MagicMock, proj
results=[
construct_timer(data_title="data title 1"),
construct_timer(data_title="data title 2"),
]
],
next_page_token=None,
)

api_client_get.return_value = return_value
Expand Down Expand Up @@ -86,7 +87,8 @@ def test_project_collaborator_timers_multi_page(api_client_get: MagicMock, proje
results=[
construct_timer(data_title="data title 3"),
construct_timer(data_title="data title 4"),
]
],
next_page_token=None,
)

api_client_get.side_effect = [return_value_page_1, return_value_page_2]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_label_rows_property_queries_metadata(project_client_mock: MagicMock, pr
def test_project_datasets(api_get: MagicMock, project: Project) -> None:
dataset_hash = uuid.uuid4()
expected_dataset = ProjectDataset(dataset_hash=dataset_hash, title="test dataset", description="my test dataset")
api_get.return_value = Page(results=[expected_dataset])
api_get.return_value = Page(results=[expected_dataset], next_page_token=None)

assert len(list(project.list_datasets())) == 1
assert list(project.list_datasets()) == [expected_dataset]
Expand Down
6 changes: 2 additions & 4 deletions tests/test_user_client_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from requests import PreparedRequest, Session

from encord.configs import SshConfig
from encord.http.v2.payloads import Page
from encord.orm.analytics import CollaboratorTimer
from encord.orm.project import Project as OrmProject
from encord.orm.project import ProjectDTO, ProjectType
from encord.user_client import EncordUserClient
Expand Down Expand Up @@ -108,8 +106,8 @@ def side_effects(*args, **kwargs):
elif args[0].path_url.startswith("/v2/public/analytics/collaborators/timers"):
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = Page[CollaboratorTimer](results=[]).to_dict()
mock_response.json.content = json.dumps(Page[CollaboratorTimer](results=[]).to_dict())
mock_response.json.return_value = {"results": [], "next_page_token": None}
mock_response.json.content = json.dumps({"results": [], "next_page_token": None})
return mock_response
elif args[0].method == "GET" and args[0].path_url.startswith("/v2/public/ontologies/"):
mock_response = MagicMock()
Expand Down

0 comments on commit 728f73a

Please sign in to comment.