from galileo_sdk.compat import mock from galileo_sdk.business.services.jobs import JobsService from galileo_sdk.mock_response import MockResponse BACKEND = "http://BACKEND" JOB_ID = "job_id" DEST_MID = "mid" FILENAME = "filename" STATION_ID = "station_id" # Arrange settings_repo = mock.Mock() settings_repo.get_settings().backend = BACKEND auth_provider = mock.Mock() auth_provider.get_access_token.return_value = "ACCESS_TOKEN" jobs_repo = mock.Mock() profile_repo = mock.Mock() jobs_service = JobsService(jobs_repo, profile_repo) def test_request_send_job(): jobs_repo.request_send_job.return_value = MockResponse( { "location": "location", "filename": "filename" }, 200) # Call r = jobs_service.request_send_job() # Assert
from galileo_sdk.business.objects.lz import ( ELzStatus, Lz, UpdateLzRequest, ) from galileo_sdk.data.repositories.lz import LzRepository from galileo_sdk.mock_response import MockResponse BACKEND = "http://BACKEND" NAMESPACE = "/galileo/user_interface/v1" LZ_ID = "lzs_id" AMOUNT = 10 UNIVERSE_ID = "universe_id" HEADERS = {"Authorization": "Bearer ACCESS_TOKEN", "universe-id": UNIVERSE_ID} # Arrange settings_repo = mock.Mock() settings_repo.get_settings().backend = BACKEND settings_repo.get_settings().universe = UNIVERSE_ID auth_provider = mock.Mock() auth_provider.get_access_token.return_value = "ACCESS_TOKEN" lz_repo = LzRepository(settings_repo, auth_provider, NAMESPACE) def mocked_requests_get(*args, **kwargs): if args[0] == "{backend}{namespace}/machines/{mid}".format( backend=BACKEND, namespace=NAMESPACE, mid=LZ_ID): x = 1 return MockResponse( { "mid": str(x), "gpu": str(x),
from galileo_sdk.compat import mock from galileo_sdk.business.objects.universes import Universe from galileo_sdk.business.services.universes import UniversesService from galileo_sdk.mock_response import MockResponse BACKEND = "http://BACKEND" JOB_ID = "job_id" DEST_MID = "mid" FILENAME = "filename" STATION_ID = "station_id" # Arrange settings_repo = mock.Mock() settings_repo.get_settings().backend = BACKEND auth_provider = mock.Mock() auth_provider.get_access_token.return_value = "ACCESS_TOKEN" universes_repo = mock.Mock() profile_repo = mock.Mock() universes_service = UniversesService(universes_repo) def test_list_universes(): universes_repo.list_universes.return_value = [ Universe("universe-id", "universe-name", "creation-timestamp") for _ in range(5) ] # Call r = universes_service.list_universes()