|
18 | 18 | from datetime import datetime
|
19 | 19 | from importlib import reload
|
20 | 20 | import json
|
| 21 | +from typing import Any, Dict |
21 | 22 | from unittest import mock
|
22 | 23 | from unittest.mock import patch
|
23 | 24 | from urllib import request
|
|
48 | 49 | import pytest
|
49 | 50 | import yaml
|
50 | 51 |
|
| 52 | +from google.protobuf import struct_pb2 |
51 | 53 | from google.protobuf import json_format
|
52 | 54 |
|
53 | 55 | _TEST_PROJECT = "test-project"
|
@@ -405,6 +407,12 @@ def mock_request_urlopen(job_spec):
|
405 | 407 | yield mock_urlopen
|
406 | 408 |
|
407 | 409 |
|
| 410 | +def dict_to_struct(d: Dict[str, Any]) -> struct_pb2.Struct: |
| 411 | + s = struct_pb2.Struct() |
| 412 | + s.update(d) |
| 413 | + return s |
| 414 | + |
| 415 | + |
408 | 416 | @pytest.mark.usefixtures("google_auth_mock")
|
409 | 417 | class TestPipelineJobSchedule:
|
410 | 418 | def setup_method(self):
|
@@ -481,7 +489,7 @@ def test_call_schedule_service_create(
|
481 | 489 | "parent": _TEST_PARENT,
|
482 | 490 | "pipeline_job": {
|
483 | 491 | "runtime_config": runtime_config,
|
484 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 492 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
485 | 493 | "service_account": _TEST_SERVICE_ACCOUNT,
|
486 | 494 | "network": _TEST_NETWORK,
|
487 | 495 | },
|
@@ -565,7 +573,7 @@ def test_call_schedule_service_create_with_different_timezone(
|
565 | 573 | "parent": _TEST_PARENT,
|
566 | 574 | "pipeline_job": {
|
567 | 575 | "runtime_config": runtime_config,
|
568 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 576 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
569 | 577 | "service_account": _TEST_SERVICE_ACCOUNT,
|
570 | 578 | "network": _TEST_NETWORK,
|
571 | 579 | },
|
@@ -647,7 +655,7 @@ def test_call_schedule_service_create_artifact_registry(
|
647 | 655 | "parent": _TEST_PARENT,
|
648 | 656 | "pipeline_job": {
|
649 | 657 | "runtime_config": runtime_config,
|
650 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 658 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
651 | 659 | "service_account": _TEST_SERVICE_ACCOUNT,
|
652 | 660 | "network": _TEST_NETWORK,
|
653 | 661 | },
|
@@ -729,7 +737,7 @@ def test_call_schedule_service_create_https(
|
729 | 737 | "parent": _TEST_PARENT,
|
730 | 738 | "pipeline_job": {
|
731 | 739 | "runtime_config": runtime_config,
|
732 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 740 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
733 | 741 | "service_account": _TEST_SERVICE_ACCOUNT,
|
734 | 742 | "network": _TEST_NETWORK,
|
735 | 743 | },
|
@@ -810,7 +818,7 @@ def test_call_schedule_service_create_with_timeout(
|
810 | 818 | "parent": _TEST_PARENT,
|
811 | 819 | "pipeline_job": {
|
812 | 820 | "runtime_config": runtime_config,
|
813 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 821 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
814 | 822 | "service_account": _TEST_SERVICE_ACCOUNT,
|
815 | 823 | "network": _TEST_NETWORK,
|
816 | 824 | },
|
@@ -890,7 +898,7 @@ def test_call_schedule_service_create_with_timeout_not_explicitly_set(
|
890 | 898 | "parent": _TEST_PARENT,
|
891 | 899 | "pipeline_job": {
|
892 | 900 | "runtime_config": runtime_config,
|
893 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 901 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
894 | 902 | "service_account": _TEST_SERVICE_ACCOUNT,
|
895 | 903 | "network": _TEST_NETWORK,
|
896 | 904 | },
|
@@ -958,7 +966,7 @@ def test_call_pipeline_job_create_schedule(
|
958 | 966 | "parent": _TEST_PARENT,
|
959 | 967 | "pipeline_job": {
|
960 | 968 | "runtime_config": runtime_config,
|
961 |
| - "pipeline_spec": {"fields": pipeline_spec}, |
| 969 | + "pipeline_spec": dict_to_struct(pipeline_spec), |
962 | 970 | "service_account": _TEST_SERVICE_ACCOUNT,
|
963 | 971 | "network": _TEST_NETWORK,
|
964 | 972 | },
|
|
0 commit comments