def test_populate_worker_pod_yaml(): environment = CloudEnvironment() file_path = os.path.dirname( prefect.environments.execution.cloud.environment.__file__) with open(path.join(file_path, "worker_pod.yaml")) as pod_file: pod = yaml.safe_load(pod_file) with set_temporary_config({ "cloud.graphql": "gql_test", "cloud.auth_token": "auth_test" }): with prefect.context(flow_run_id="id_test", image="my_image"): yaml_obj = environment._populate_worker_pod_yaml(yaml_obj=pod) assert yaml_obj["metadata"]["labels"][ "identifier"] == environment.identifier_label assert yaml_obj["metadata"]["labels"]["flow_run_id"] == "id_test" env = yaml_obj["spec"]["containers"][0]["env"] assert env[0]["value"] == "gql_test" assert env[1]["value"] == "auth_test" assert env[2]["value"] == "id_test" assert yaml_obj["spec"]["containers"][0]["image"] == "my_image"
def test_populate_worker_pod_yaml_with_private_registry(): environment = CloudEnvironment(private_registry=True) file_path = os.path.dirname( prefect.environments.execution.cloud.environment.__file__) with open(path.join(file_path, "worker_pod.yaml")) as pod_file: pod = yaml.safe_load(pod_file) with set_temporary_config({ "cloud.graphql": "gql_test", "cloud.auth_token": "auth_test" }): with prefect.context(flow_run_id="id_test", image="my_image", namespace="foo-man"): yaml_obj = environment._populate_worker_pod_yaml(yaml_obj=pod) yaml_obj["spec"]["imagePullSecrets"][0] == dict(name="foo-man-docker")