Skip to content

Commit ff253f9

Browse files
feat: Add ExternalRuntimeOptions to BigQuery routine
This change introduces the `ExternalRuntimeOptions` class to the `google.cloud.bigquery.routine` module, allowing users to configure runtime options for external routines. Key changes: - Created the `ExternalRuntimeOptions` class with setters and getters for `container_memory`, `container_cpu`, `runtime_connection`, `max_batching_rows`, and `runtime_version`. - Updated the `Routine` class to include an `external_runtime_options` property that accepts an `ExternalRuntimeOptions` object. - Added comprehensive unit tests for the new class and its integration with the `Routine` class, including tests for both valid and invalid input values. - Added additional tests to improve code coverage based on feedback.
1 parent 4679101 commit ff253f9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/unit/routine/test_external_runtime_options.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@ def test_runtime_version(object_under_test):
8181
assert object_under_test.runtime_version == runtime_version
8282

8383

84+
def test_ctor_w_properties(target_class):
85+
properties = {
86+
"containerMemory": "1G",
87+
"containerCpu": 1,
88+
}
89+
instance = target_class(_properties=properties)
90+
assert instance._properties == properties
91+
92+
93+
def test_ne(target_class):
94+
instance1 = target_class(container_memory="1G")
95+
instance2 = target_class(container_memory="2G")
96+
assert instance1 != instance2
97+
98+
99+
def test_ne_false(target_class):
100+
instance1 = target_class(container_memory="1G")
101+
instance2 = target_class(container_memory="1G")
102+
assert not (instance1 != instance2)
103+
104+
105+
def test_eq_not_implemented(object_under_test):
106+
assert not (object_under_test == object())
107+
assert object_under_test != object()
108+
109+
84110
def test_from_api_repr(target_class):
85111
resource = {
86112
"containerMemory": "1G",

tests/unit/routine/test_routine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ def test_set_remote_function_options_w_none(object_under_test):
607607
assert object_under_test._properties["remoteFunctionOptions"] is None
608608

609609

610+
def test_set_external_runtime_options_w_none(object_under_test):
611+
object_under_test.external_runtime_options = None
612+
assert object_under_test.external_runtime_options is None
613+
assert object_under_test._properties["externalRuntimeOptions"] is None
614+
615+
610616
def test_set_data_governance_type_w_none(object_under_test):
611617
object_under_test.data_governance_type = None
612618
assert object_under_test.data_governance_type is None

0 commit comments

Comments
 (0)