From fb049eccaf72dca326b33a03212db3c2b38b8c97 Mon Sep 17 00:00:00 2001 From: Jericho Tolentino <68654047+jericht@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:57:56 +0000 Subject: [PATCH] chore: updates for compatibility with deadline-cloud-test-fixtures Signed-off-by: Jericho Tolentino <68654047+jericht@users.noreply.github.com> --- test/conftest.py | 130 ------------------------------------------ test/unit/conftest.py | 112 +++++++++++++++++++++++++++++++++++- 2 files changed, 111 insertions(+), 131 deletions(-) delete mode 100644 test/conftest.py diff --git a/test/conftest.py b/test/conftest.py deleted file mode 100644 index 04f8db16..00000000 --- a/test/conftest.py +++ /dev/null @@ -1,130 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - -from __future__ import annotations - -import secrets -import string -from typing import Optional - - -import pytest - -from deadline_worker_agent.installer import ( - ParsedCommandLineArguments, -) - -VFS_DEFAULT_INSTALL_PATH = "/opt/deadline_vfs" - - -@pytest.fixture -def farm_id() -> str: - return "farm-123e4567e89b12d3a456426655441234" - - -@pytest.fixture -def fleet_id() -> str: - return "fleet-123e4567e89b12d3a456426655444321" - - -@pytest.fixture -def region() -> str: - return "us-west-2" - - -@pytest.fixture -def user() -> str: - return "wa_user" - - -@pytest.fixture -def password() -> str: - alphabet = string.ascii_letters + string.digits + string.punctuation - return "".join(secrets.choice(alphabet) for _ in range(12)) - - -# @pytest.fixture(params=("wa_group", None)) -@pytest.fixture(params=("wa_group",)) -def group(request: pytest.FixtureRequest) -> Optional[str]: - return request.param - - -@pytest.fixture -def service_start() -> bool: - return False - - -@pytest.fixture -def confirmed() -> bool: - return True - - -@pytest.fixture -def allow_shutdown() -> bool: - return False - - -@pytest.fixture -def telemetry_opt_out() -> bool: - return True - - -@pytest.fixture -def install_service() -> bool: - return True - - -@pytest.fixture -def vfs_install_path() -> str: - return VFS_DEFAULT_INSTALL_PATH - - -@pytest.fixture -def grant_required_access() -> bool: - return True - - -@pytest.fixture -def disallow_instance_profile() -> bool: - return True - - -@pytest.fixture -def parsed_args( - farm_id: str, - fleet_id: str, - region: str, - user: str, - password: Optional[str], - group: Optional[str], - service_start: bool, - confirmed: bool, - allow_shutdown: bool, - install_service: bool, - telemetry_opt_out: bool, - vfs_install_path: str, - grant_required_access: bool, - disallow_instance_profile: bool, -) -> ParsedCommandLineArguments: - parsed_args = ParsedCommandLineArguments() - parsed_args.farm_id = farm_id - parsed_args.fleet_id = fleet_id - parsed_args.user = user - parsed_args.password = password - parsed_args.group = group - parsed_args.region = region - parsed_args.service_start = service_start - parsed_args.confirmed = confirmed - parsed_args.allow_shutdown = allow_shutdown - parsed_args.install_service = install_service - parsed_args.telemetry_opt_out = telemetry_opt_out - parsed_args.vfs_install_path = vfs_install_path - parsed_args.grant_required_access = grant_required_access - parsed_args.disallow_instance_profile = disallow_instance_profile - return parsed_args - - -@pytest.fixture( - params=("linux",), -) -def platform(request: pytest.FixtureRequest) -> str: - return request.param diff --git a/test/unit/conftest.py b/test/unit/conftest.py index c34e68bb..015a8343 100644 --- a/test/unit/conftest.py +++ b/test/unit/conftest.py @@ -1,9 +1,11 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - from __future__ import annotations from unittest.mock import MagicMock, patch import os +import secrets +import string +from typing import Optional import pytest from pytest import FixtureRequest @@ -29,6 +31,9 @@ ) from deadline_worker_agent.api_models import HostProperties, IpAddresses +from deadline_worker_agent.installer import ( + ParsedCommandLineArguments, +) from deadline_worker_agent.sessions.job_entities.job_details import ( JobAttachmentSettings, JobDetails, @@ -40,6 +45,111 @@ ) from deadline_worker_agent.startup.config import JobsRunAsUserOverride +VFS_DEFAULT_INSTALL_PATH = "/opt/deadline_vfs" + + +@pytest.fixture +def region() -> str: + return "us-west-2" + + +@pytest.fixture +def user() -> str: + return "wa_user" + + +@pytest.fixture +def password() -> str: + alphabet = string.ascii_letters + string.digits + string.punctuation + return "".join(secrets.choice(alphabet) for _ in range(12)) + + +@pytest.fixture(params=("wa_group",)) +def group(request: pytest.FixtureRequest) -> Optional[str]: + return request.param + + +@pytest.fixture +def service_start() -> bool: + return False + + +@pytest.fixture +def confirmed() -> bool: + return True + + +@pytest.fixture +def allow_shutdown() -> bool: + return False + + +@pytest.fixture +def telemetry_opt_out() -> bool: + return True + + +@pytest.fixture +def install_service() -> bool: + return True + + +@pytest.fixture +def vfs_install_path() -> str: + return VFS_DEFAULT_INSTALL_PATH + + +@pytest.fixture +def grant_required_access() -> bool: + return True + + +@pytest.fixture +def disallow_instance_profile() -> bool: + return True + + +@pytest.fixture +def parsed_args( + farm_id: str, + fleet_id: str, + region: str, + user: str, + password: Optional[str], + group: Optional[str], + service_start: bool, + confirmed: bool, + allow_shutdown: bool, + install_service: bool, + telemetry_opt_out: bool, + vfs_install_path: str, + grant_required_access: bool, + disallow_instance_profile: bool, +) -> ParsedCommandLineArguments: + parsed_args = ParsedCommandLineArguments() + parsed_args.farm_id = farm_id + parsed_args.fleet_id = fleet_id + parsed_args.user = user + parsed_args.password = password + parsed_args.group = group + parsed_args.region = region + parsed_args.service_start = service_start + parsed_args.confirmed = confirmed + parsed_args.allow_shutdown = allow_shutdown + parsed_args.install_service = install_service + parsed_args.telemetry_opt_out = telemetry_opt_out + parsed_args.vfs_install_path = vfs_install_path + parsed_args.grant_required_access = grant_required_access + parsed_args.disallow_instance_profile = disallow_instance_profile + return parsed_args + + +@pytest.fixture( + params=("linux",), +) +def platform(request: pytest.FixtureRequest) -> str: + return request.param + @pytest.fixture def client() -> MagicMock: