Skip to content

Commit 048df4f

Browse files
- Added robot test Update Async Returning Simple Projection.
- Added robot test `Replace Returning Simple Projection`. - Added robot test `Replace Async Returning Simple Projection`.
1 parent 86d8a4f commit 048df4f

File tree

13 files changed

+231
-16
lines changed

13 files changed

+231
-16
lines changed

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
"insert /*+ AWAIT */ into google.compute.networks(project, data__name, data__autoCreateSubnetworks) select 'mutable-project', 'auto-test-01', false returning creationTimestamp, name;",
180180
"registry pull google 'v0.1.2'; show resources in google.storage; registry pull google 'v0.1.1-alpha01'; show resources in google.storage; registry pull google 'v0.1.0'; show resources in google.storage;",
181181
"update google.storage.buckets set data__labels = '{ \"app_stub\": \"factory\" }' where bucket = 'demo-app-bucket1' returning labels, projectNumber;",
182+
"update google.compute.firewalls set data__disabled = 'true' where project = 'mutable-project' and firewall = 'updatable-firewall' returning user;",
182183
],
183184
"default": "show providers;"
184185
},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/spf13/cobra v1.4.0
2020
github.com/spf13/pflag v1.0.5
2121
github.com/spf13/viper v1.10.1
22-
github.com/stackql/any-sdk v0.1.4-alpha11
22+
github.com/stackql/any-sdk v0.1.4-alpha12
2323
github.com/stackql/go-suffix-map v0.0.1-alpha01
2424
github.com/stackql/psql-wire v0.1.1-beta23
2525
github.com/stackql/stackql-parser v0.0.15-alpha06

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
484484
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
485485
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
486486
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
487-
github.com/stackql/any-sdk v0.1.4-alpha11 h1:WeFvLcml37sq+HbVk3hiXuImQ578SE9LM/K1MzqFovo=
488-
github.com/stackql/any-sdk v0.1.4-alpha11/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
487+
github.com/stackql/any-sdk v0.1.4-alpha12 h1:SozoNb4+7+y+0bVGmO8ozFtTTpYhEWBHVDuN9SmkFuA=
488+
github.com/stackql/any-sdk v0.1.4-alpha12/go.mod h1:AKS/g28y7m4SWL/YW8veE9MCNy8XJgaicVibemVE9e8=
489489
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
490490
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
491491
github.com/stackql/psql-wire v0.1.1-beta23 h1:1ayYMjZArfDcIMyEOKnm+Bp1zRCISw8pguvTFuUhhVQ=

interactive_console_output.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<robot generator="Robot 7.0.1 (Python 3.13.2 on darwin)" generated="2025-07-14T18:18:36.580447" rpa="false" schemaversion="5">
3+
<suite id="s1" name="Robot Interactive Console" source="/Users/admin/.vscode/extensions/robocorp.robotframework-lsp-1.13.0/src/robotframework_ls/vendored/robotframework_interactive/robot_interactive_console.robot">
4+
<test id="s1-t1" name="Default Task/Test" line="5">
5+
<kw name="Interpreter Main Loop" owner="MainLoop">
6+
<status status="PASS" start="2025-07-14T18:18:36.624033" elapsed="2.359496"/>
7+
</kw>
8+
<status status="PASS" start="2025-07-14T18:18:36.623570" elapsed="2.360181"/>
9+
</test>
10+
<status status="PASS" start="2025-07-14T18:18:36.581973" elapsed="2.402413"/>
11+
</suite>
12+
<statistics>
13+
<total>
14+
<stat pass="1" fail="0" skip="0">All Tests</stat>
15+
</total>
16+
<tag>
17+
</tag>
18+
<suite>
19+
<stat pass="1" fail="0" skip="0" id="s1" name="Robot Interactive Console">Robot Interactive Console</stat>
20+
</suite>
21+
</statistics>
22+
<errors>
23+
<msg time="2025-07-14T18:18:36.574328" level="WARN">Error in file '/Users/admin/.vscode/extensions/robocorp.robotframework-lsp-1.13.0/src/robotframework_ls/vendored/robotframework_interactive/robot_interactive_console.robot' on line 4: Singular section headers like '*** Test Case ***' are deprecated. Use plural format like '*** Test Cases ***' instead.</msg>
24+
</errors>
25+
</robot>

internal/stackql/primitivebuilder/exec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (ss *Exec) Build() error {
8787
svc,
8888
true,
8989
[]anysdk.ColumnDescriptor{},
90+
false,
9091
)
9192
analyser := anysdk.NewMethodAnalyzer()
9293
methodAnalysisOutput, analysisErr := analyser.AnalyzeUnaryAction(analysisInput)

internal/stackql/primitivegenerator/statement_analyzer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ func (pb *standardPrimitiveGenerator) AnalyzeUnaryExec(
639639
svc,
640640
true,
641641
[]anysdk.ColumnDescriptor{},
642+
false,
642643
)
643644
analyser := anysdk.NewMethodAnalyzer()
644645
methodAnalysisOutput, analysisErr := analyser.AnalyzeUnaryAction(analysisInput)
@@ -1137,6 +1138,7 @@ func (pb *standardPrimitiveGenerator) AnalyzeInsert(pbi planbuilderinput.PlanBui
11371138
svc,
11381139
true,
11391140
[]anysdk.ColumnDescriptor{},
1141+
pb.PrimitiveComposer.IsAwait(),
11401142
)
11411143
analyser := anysdk.NewMethodAnalyzer()
11421144
// TODO: this ought to cater for async
@@ -1258,6 +1260,7 @@ func (pb *standardPrimitiveGenerator) AnalyzeUpdate(pbi planbuilderinput.PlanBui
12581260
svc,
12591261
true,
12601262
[]anysdk.ColumnDescriptor{},
1263+
pb.PrimitiveComposer.IsAwait(),
12611264
)
12621265
analyser := anysdk.NewMethodAnalyzer()
12631266
methodAnalysisOutput, analysisErr := analyser.AnalyzeUnaryAction(analysisInput)
@@ -1350,6 +1353,7 @@ func (pb *standardPrimitiveGenerator) analyzeDelete(
13501353
svc,
13511354
true,
13521355
[]anysdk.ColumnDescriptor{},
1356+
pb.PrimitiveComposer.IsAwait(),
13531357
)
13541358
analyser := anysdk.NewMethodAnalyzer()
13551359
methodAnalysisOutput, analysisErr := analyser.AnalyzeUnaryAction(analysisInput)

test/python/stackql_test_tooling/flask/gcp/app.py

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,27 @@ def compute_networks_insert(project_name: str):
7474
), 200, {'Content-Type': 'application/json'}
7575
return '{"msg": "Disallowed"}', 401, {'Content-Type': 'application/json'}
7676

77+
def _extrapolate_target_from_operation(operation_name: str, project_name: str, host_name: str) -> str:
78+
"""
79+
Extrapolates the target link from the operation name and project name.
80+
"""
81+
if project_name == 'mutable-project' and operation_name == 'operation-100000000001-10000000001-10000001-10000001':
82+
network_name = 'auto-test-01'
83+
return f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/networks/{ network_name }'
84+
if project_name == 'mutable-project' and operation_name == 'operation-100000000002-10000000002-10000002-10000002':
85+
firewall_name = 'replacable-firewall'
86+
return f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/firewalls/{ firewall_name }'
87+
if project_name == 'mutable-project' and operation_name == 'operation-100000000003-10000000003-10000003-10000003':
88+
firewall_name = 'updatable-firewall'
89+
return f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/firewalls/{ firewall_name }'
90+
raise ValueError(f"Unsupported operation name: {operation_name} for project: {project_name}")
91+
7792
@app.route('/compute/v1/projects/<project_name>/global/operations/<operation_name>', methods=['GET'])
7893
def projects_testing_project_global_operation_detail(project_name: str, operation_name: str):
79-
if project_name == 'mutable-project' and 'operation-100000000001-10000000001-10000001-10000001':
94+
try:
8095
operation_id = '1000000000001'
81-
network_name = 'auto-test-01'
8296
host_name = 'host.docker.internal' if _IS_DOCKER else 'localhost'
83-
target_link = f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/networks/{ network_name }'
97+
target_link = _extrapolate_target_from_operation(operation_name, project_name, host_name)
8498
return render_template(
8599
'global-operation.jinja.json',
86100
target_link=target_link,
@@ -93,7 +107,8 @@ def projects_testing_project_global_operation_detail(project_name: str, operatio
93107
progress=100,
94108
end_time='2025-07-05T19:43:34.491-07:00',
95109
), 200, {'Content-Type': 'application/json'}
96-
return '{"msg": "Disallowed"}', 401, {'Content-Type': 'application/json'}
110+
except:
111+
return '{"msg": "Disallowed"}', 401, {'Content-Type': 'application/json'}
97112

98113
@app.route('/compute/v1/projects/<project_name>/global/networks/<network_name>', methods=['GET'])
99114
def projects_testing_project_global_network_detail(project_name: str, network_name: str):
@@ -281,13 +296,69 @@ def v1_projects_testing_project_assets():
281296
# Increment the call counter
282297
return render_template('route_32_template.json'), 200, {'Content-Type': 'application/json'}
283298

284-
@app.route('/compute/v1/projects/testing-project/global/firewalls/allow-spark-ui', methods=['PUT'])
285-
def projects_testing_project_global_firewalls_allow_spark_ui():
286-
return render_template('route_33_template.json'), 200, {'Content-Type': 'application/json'}
299+
@app.route('/compute/v1/projects/<project_name>/global/firewalls/<firewall_name>', methods=['PUT'])
300+
def projects_testing_project_global_firewalls_replace(project_name: str, firewall_name: str):
301+
_permitted_combinations = (('testing-project', 'allow-spark-ui'), ('mutable-project', 'replacable-firewall'))
302+
if (project_name, firewall_name) not in _permitted_combinations:
303+
return '{"msg": "Disallowed"}', 500, {'Content-Type': 'application/json'}
304+
body = request.get_json()
305+
operation_id = '1000000000002'
306+
operation_name = 'operation-100000000002-10000000002-10000002-10000002'
307+
host_name = 'host.docker.internal' if _IS_DOCKER else 'localhost'
308+
target_link = f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/firewalls/{ firewall_name }'
309+
if not body:
310+
return '{"msg": "Invalid request body"}', 400, {'Content-Type': 'application/json'}
311+
if not project_name:
312+
return '{"msg": "Invalid request: project not supplied"}', 400, {'Content-Type': 'application/json'}
313+
return render_template(
314+
'global-operation.jinja.json',
315+
target_link=target_link,
316+
operation_id=operation_id,
317+
operation_name=operation_name,
318+
project_name=project_name,
319+
host_name=host_name,
320+
kind='compute#operation',
321+
operation_type='put',
322+
progress=0,
323+
), 200, {'Content-Type': 'application/json'}
324+
325+
@app.route('/compute/v1/projects/<project_name>/global/firewalls/<firewall_name>', methods=['PATCH'])
326+
def projects_testing_project_global_firewalls_update(project_name: str, firewall_name: str):
327+
_permitted_combinations = (('testing-project', 'some-other-firewall'), ('mutable-project', 'updatable-firewall'))
328+
if (project_name, firewall_name) not in _permitted_combinations:
329+
return '{"msg": "Disallowed"}', 500, {'Content-Type': 'application/json'}
330+
body = request.get_json()
331+
operation_id = '1000000000003'
332+
operation_name = 'operation-100000000003-10000000003-10000003-10000003'
333+
host_name = 'host.docker.internal' if _IS_DOCKER else 'localhost'
334+
target_link = f'https://{host_name}:1080/compute/v1/projects/{ project_name }/global/firewalls/{ firewall_name }'
335+
if not body:
336+
return '{"msg": "Invalid request body"}', 400, {'Content-Type': 'application/json'}
337+
if not project_name:
338+
return '{"msg": "Invalid request: project not supplied"}', 400, {'Content-Type': 'application/json'}
339+
return render_template(
340+
'global-operation.jinja.json',
341+
target_link=target_link,
342+
operation_id=operation_id,
343+
operation_name=operation_name,
344+
project_name=project_name,
345+
host_name=host_name,
346+
kind='compute#operation',
347+
operation_type='patch',
348+
progress=0,
349+
), 200, {'Content-Type': 'application/json'}
287350

288-
@app.route('/compute/v1/projects/testing-project/global/firewalls/some-other-firewall', methods=['PATCH'])
289-
def projects_testing_project_global_firewalls_some_other_firewall():
290-
return render_template('route_34_template.json'), 200, {'Content-Type': 'application/json'}
351+
@app.route('/compute/v1/projects/<project_name>/global/firewalls/<firewall_name>', methods=['GET'])
352+
def projects_testing_project_global_firewalls_some_other_firewall(project_name: str, firewall_name: str):
353+
_permitted_combinations = (('testing-project', 'some-other-firewall'), ('mutable-project', 'updatable-firewall'), ('mutable-project', 'replacable-firewall'))
354+
if (project_name, firewall_name) not in _permitted_combinations:
355+
return '{"msg": "Disallowed"}', 500, {'Content-Type': 'application/json'}
356+
jinja_context = {
357+
'project_name': project_name,
358+
'firewall_name': firewall_name,
359+
'host_name': 'host.docker.internal' if _IS_DOCKER else 'localhost',
360+
}
361+
return render_template('firewall-detail.jinja.json', **jinja_context), 200, {'Content-Type': 'application/json'}
291362

292363
@app.route('/compute/v1/projects/testing-project/global/firewalls', methods=['GET'])
293364
def projects_testing_project_global_firewalls():
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"kind": "compute#firewall",
3+
"id": "100000000001",
4+
"creationTimestamp": "2025-07-13T22:08:28.822-07:00",
5+
"name": "{{ firewall_name }}",
6+
"description": "My test fw rule",
7+
"network": "https://www.googleapis.com/compute/v1/projects/{{ project_name }}/global/networks/nw-test-02",
8+
"priority": 1000,
9+
"sourceRanges": [
10+
"0.0.0.0/0"
11+
],
12+
"allowed": [
13+
{
14+
"IPProtocol": "all"
15+
}
16+
],
17+
"direction": "INGRESS",
18+
"logConfig": {
19+
"enable": false
20+
},
21+
"disabled": false,
22+
"selfLink": "https://www.googleapis.com/compute/v1/projects/{{ project_name }}/global/firewalls/{{ firewall_name }}"
23+
}

test/python/stackql_test_tooling/flask/gcp/templates/global-operation.jinja.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"targetLink": "{{ target_link }}",
77
"targetId": "{{ target_id if target_id else '2000000000002' }}",
88
"status": "{{ 'DONE' if progress and progress > 99 else 'RUNNING' }}",
9-
"user": "[email protected]",
9+
"user": "[email protected]",
1010
"progress": {{ progress }},
1111
"insertTime": "2025-07-05T19:42:34.488-07:00",
1212
"startTime": "2025-07-05T19:42:34.491-07:00",

test/python/stackql_test_tooling/flask/gcp/templates/route_33_template.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)