1818import pytest
1919
2020import google .cloud ._helpers
21+ from google .cloud import bigquery
2122from google .cloud import bigquery_v2
2223
2324
@@ -73,6 +74,7 @@ def test_ctor_w_properties(target_class):
7374 )
7475 type_ = "SCALAR_FUNCTION"
7576 description = "A routine description."
77+ determinism_level = bigquery .DeterminismLevel .NOT_DETERMINISTIC
7678
7779 actual_routine = target_class (
7880 routine_id ,
@@ -82,6 +84,7 @@ def test_ctor_w_properties(target_class):
8284 return_type = return_type ,
8385 type_ = type_ ,
8486 description = description ,
87+ determinism_level = determinism_level ,
8588 )
8689
8790 ref = RoutineReference .from_string (routine_id )
@@ -92,6 +95,9 @@ def test_ctor_w_properties(target_class):
9295 assert actual_routine .return_type == return_type
9396 assert actual_routine .type_ == type_
9497 assert actual_routine .description == description
98+ assert (
99+ actual_routine .determinism_level == bigquery .DeterminismLevel .NOT_DETERMINISTIC
100+ )
95101
96102
97103def test_from_api_repr (target_class ):
@@ -120,6 +126,7 @@ def test_from_api_repr(target_class):
120126 "routineType" : "SCALAR_FUNCTION" ,
121127 "someNewField" : "someValue" ,
122128 "description" : "A routine description." ,
129+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISTIC ,
123130 }
124131 actual_routine = target_class .from_api_repr (resource )
125132
@@ -152,6 +159,7 @@ def test_from_api_repr(target_class):
152159 assert actual_routine .type_ == "SCALAR_FUNCTION"
153160 assert actual_routine ._properties ["someNewField" ] == "someValue"
154161 assert actual_routine .description == "A routine description."
162+ assert actual_routine .determinism_level == "DETERMINISTIC"
155163
156164
157165def test_from_api_repr_w_minimal_resource (target_class ):
@@ -177,6 +185,7 @@ def test_from_api_repr_w_minimal_resource(target_class):
177185 assert actual_routine .return_type is None
178186 assert actual_routine .type_ is None
179187 assert actual_routine .description is None
188+ assert actual_routine .determinism_level is None
180189
181190
182191def test_from_api_repr_w_unknown_fields (target_class ):
@@ -208,6 +217,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
208217 "returnType" : {"typeKind" : "INT64" },
209218 "routineType" : "SCALAR_FUNCTION" ,
210219 "description" : "A routine description." ,
220+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
211221 },
212222 ["arguments" ],
213223 {"arguments" : [{"name" : "x" , "dataType" : {"typeKind" : "INT64" }}]},
@@ -220,6 +230,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
220230 "returnType" : {"typeKind" : "INT64" },
221231 "routineType" : "SCALAR_FUNCTION" ,
222232 "description" : "A routine description." ,
233+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
223234 },
224235 ["body" ],
225236 {"definitionBody" : "x * 3" },
@@ -232,6 +243,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
232243 "returnType" : {"typeKind" : "INT64" },
233244 "routineType" : "SCALAR_FUNCTION" ,
234245 "description" : "A routine description." ,
246+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
235247 },
236248 ["language" ],
237249 {"language" : "SQL" },
@@ -244,6 +256,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
244256 "returnType" : {"typeKind" : "INT64" },
245257 "routineType" : "SCALAR_FUNCTION" ,
246258 "description" : "A routine description." ,
259+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
247260 },
248261 ["return_type" ],
249262 {"returnType" : {"typeKind" : "INT64" }},
@@ -256,6 +269,7 @@ def test_from_api_repr_w_unknown_fields(target_class):
256269 "returnType" : {"typeKind" : "INT64" },
257270 "routineType" : "SCALAR_FUNCTION" ,
258271 "description" : "A routine description." ,
272+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
259273 },
260274 ["type_" ],
261275 {"routineType" : "SCALAR_FUNCTION" },
@@ -268,20 +282,45 @@ def test_from_api_repr_w_unknown_fields(target_class):
268282 "returnType" : {"typeKind" : "INT64" },
269283 "routineType" : "SCALAR_FUNCTION" ,
270284 "description" : "A routine description." ,
285+ "determinismLevel" : bigquery .DeterminismLevel .DETERMINISM_LEVEL_UNSPECIFIED ,
271286 },
272287 ["description" ],
273288 {"description" : "A routine description." },
274289 ),
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+ ),
275305 (
276306 {},
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+ ],
278316 {
279317 "arguments" : None ,
280318 "definitionBody" : None ,
281319 "language" : None ,
282320 "returnType" : None ,
283321 "routineType" : None ,
284322 "description" : None ,
323+ "determinismLevel" : None ,
285324 },
286325 ),
287326 (
0 commit comments