|
18 | 18 | import pytest
|
19 | 19 |
|
20 | 20 | import google.cloud._helpers
|
| 21 | +from google.cloud import bigquery |
21 | 22 | from google.cloud import bigquery_v2
|
22 | 23 |
|
23 | 24 |
|
@@ -73,6 +74,7 @@ def test_ctor_w_properties(target_class):
|
73 | 74 | )
|
74 | 75 | type_ = "SCALAR_FUNCTION"
|
75 | 76 | description = "A routine description."
|
| 77 | +determinism_level = bigquery.DeterminismLevel.NOT_DETERMINISTIC |
76 | 78 |
|
77 | 79 | actual_routine = target_class(
|
78 | 80 | routine_id,
|
@@ -82,6 +84,7 @@ def test_ctor_w_properties(target_class):
|
82 | 84 | return_type=return_type,
|
83 | 85 | type_=type_,
|
84 | 86 | description=description,
|
| 87 | +determinism_level=determinism_level, |
85 | 88 | )
|
86 | 89 |
|
87 | 90 | ref = RoutineReference.from_string(routine_id)
|
@@ -92,6 +95,9 @@ def test_ctor_w_properties(target_class):
|
92 | 95 | assert actual_routine.return_type == return_type
|
93 | 96 | assert actual_routine.type_ == type_
|
94 | 97 | assert actual_routine.description == description
|
| 98 | +assert ( |
| 99 | +actual_routine.determinism_level == bigquery.DeterminismLevel.NOT_DETERMINISTIC |
| 100 | +) |
95 | 101 |
|
96 | 102 |
|
97 | 103 | def test_from_api_repr(target_class):
|
@@ -120,6 +126,7 @@ def test_from_api_repr(target_class):
|
120 | 126 | "routineType": "SCALAR_FUNCTION",
|
121 | 127 | "someNewField": "someValue",
|
122 | 128 | "description": "A routine description.",
|
| 129 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISTIC, |
123 | 130 | }
|
124 | 131 | actual_routine = target_class.from_api_repr(resource)
|
125 | 132 |
|
@@ -152,6 +159,7 @@ def test_from_api_repr(target_class):
|
152 | 159 | assert actual_routine.type_ == "SCALAR_FUNCTION"
|
153 | 160 | assert actual_routine._properties["someNewField"] == "someValue"
|
154 | 161 | assert actual_routine.description == "A routine description."
|
| 162 | +assert actual_routine.determinism_level == "DETERMINISTIC" |
155 | 163 |
|
156 | 164 |
|
157 | 165 | def test_from_api_repr_w_minimal_resource(target_class):
|
@@ -177,6 +185,7 @@ def test_from_api_repr_w_minimal_resource(target_class):
|
177 | 185 | assert actual_routine.return_type is None
|
178 | 186 | assert actual_routine.type_ is None
|
179 | 187 | assert actual_routine.description is None
|
| 188 | +assert actual_routine.determinism_level is None |
180 | 189 |
|
181 | 190 |
|
182 | 191 | def test_from_api_repr_w_unknown_fields(target_class):
|
@@ -208,6 +217,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
208 | 217 | "returnType": {"typeKind": "INT64"},
|
209 | 218 | "routineType": "SCALAR_FUNCTION",
|
210 | 219 | "description": "A routine description.",
|
| 220 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
211 | 221 | },
|
212 | 222 | ["arguments"],
|
213 | 223 | {"arguments": [{"name": "x", "dataType": {"typeKind": "INT64"}}]},
|
@@ -220,6 +230,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
220 | 230 | "returnType": {"typeKind": "INT64"},
|
221 | 231 | "routineType": "SCALAR_FUNCTION",
|
222 | 232 | "description": "A routine description.",
|
| 233 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
223 | 234 | },
|
224 | 235 | ["body"],
|
225 | 236 | {"definitionBody": "x * 3"},
|
@@ -232,6 +243,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
232 | 243 | "returnType": {"typeKind": "INT64"},
|
233 | 244 | "routineType": "SCALAR_FUNCTION",
|
234 | 245 | "description": "A routine description.",
|
| 246 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
235 | 247 | },
|
236 | 248 | ["language"],
|
237 | 249 | {"language": "SQL"},
|
@@ -244,6 +256,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
244 | 256 | "returnType": {"typeKind": "INT64"},
|
245 | 257 | "routineType": "SCALAR_FUNCTION",
|
246 | 258 | "description": "A routine description.",
|
| 259 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
247 | 260 | },
|
248 | 261 | ["return_type"],
|
249 | 262 | {"returnType": {"typeKind": "INT64"}},
|
@@ -256,6 +269,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
256 | 269 | "returnType": {"typeKind": "INT64"},
|
257 | 270 | "routineType": "SCALAR_FUNCTION",
|
258 | 271 | "description": "A routine description.",
|
| 272 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
259 | 273 | },
|
260 | 274 | ["type_"],
|
261 | 275 | {"routineType": "SCALAR_FUNCTION"},
|
@@ -268,20 +282,45 @@ def test_from_api_repr_w_unknown_fields(target_class):
|
268 | 282 | "returnType": {"typeKind": "INT64"},
|
269 | 283 | "routineType": "SCALAR_FUNCTION",
|
270 | 284 | "description": "A routine description.",
|
| 285 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
271 | 286 | },
|
272 | 287 | ["description"],
|
273 | 288 | {"description": "A routine description."},
|
274 | 289 | ),
|
| 290 | +( |
| 291 | +{ |
| 292 | +"arguments": [{"name": "x", "dataType": {"typeKind": "INT64"}}], |
| 293 | +"definitionBody": "x * 3", |
| 294 | +"language": "SQL", |
| 295 | +"returnType": {"typeKind": "INT64"}, |
| 296 | +"routineType": "SCALAR_FUNCTION", |
| 297 | +"description": "A routine description.", |
| 298 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED, |
| 299 | +}, |
| 300 | +["determinism_level"], |
| 301 | +{ |
| 302 | +"determinismLevel": bigquery.DeterminismLevel.DETERMINISM_LEVEL_UNSPECIFIED |
| 303 | +}, |
| 304 | +), |
275 | 305 | (
|
276 | 306 | {},
|
277 |
| -["arguments", "language", "body", "type_", "return_type", "description"], |
| 307 | +[ |
| 308 | +"arguments", |
| 309 | +"language", |
| 310 | +"body", |
| 311 | +"type_", |
| 312 | +"return_type", |
| 313 | +"description", |
| 314 | +"determinism_level", |
| 315 | +], |
278 | 316 | {
|
279 | 317 | "arguments": None,
|
280 | 318 | "definitionBody": None,
|
281 | 319 | "language": None,
|
282 | 320 | "returnType": None,
|
283 | 321 | "routineType": None,
|
284 | 322 | "description": None,
|
| 323 | +"determinismLevel": None, |
285 | 324 | },
|
286 | 325 | ),
|
287 | 326 | (
|
|
0 commit comments