diff --git a/tests/New_ATS/Tests/enum-oneof/Impl/Start Sync.vi b/tests/New_ATS/Tests/enum-oneof/Impl/Start Sync.vi index ffd026ef..d5005420 100644 Binary files a/tests/New_ATS/Tests/enum-oneof/Impl/Start Sync.vi and b/tests/New_ATS/Tests/enum-oneof/Impl/Start Sync.vi differ diff --git a/tests/New_ATS/Tests/enum-oneof/enum-oneof_client.py b/tests/New_ATS/Tests/enum-oneof/enum-oneof_client.py index 6ccfc2be..031cfd28 100644 --- a/tests/New_ATS/Tests/enum-oneof/enum-oneof_client.py +++ b/tests/New_ATS/Tests/enum-oneof/enum-oneof_client.py @@ -16,7 +16,7 @@ def get_GetFeature_output(test_input): response_dict = {} response_dict['res_latitude'] = response.res_latitude response_dict['res_oneof'] = {} - response_dict['res_oneof']['res_color'] = enum_oneof_pb2.Color(response.res_color) if response.HasField('res_color') else None + response_dict['res_oneof']['res_color'] = enum_oneof_pb2.Color.Name(response.res_color) if response.HasField('res_color') else None response_dict['res_oneof']['res_name'] = response.res_name if response.HasField('res_name') else None return(response_dict) diff --git a/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto b/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto index 4928a221..050c79e4 100644 --- a/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto +++ b/tests/New_ATS/Tests/multiple-field-oneof/multiple-field-oneof.proto @@ -11,8 +11,8 @@ message res { oneof res_oneof { string res_name = 2; int32 res_num = 3; - bool flag = 4; float price = 5; + bool flag = 4; } } @@ -21,7 +21,7 @@ message req { oneof req_oneof { string req_name = 2; int32 req_num = 3; - bool flag = 4; float price = 5; + bool flag = 4; } } \ No newline at end of file diff --git a/tests/New_ATS/Tests/nested-oneof/Impl/Start Sync.vi b/tests/New_ATS/Tests/nested-oneof/Impl/Start Sync.vi index 45e6d38d..77a94b69 100644 Binary files a/tests/New_ATS/Tests/nested-oneof/Impl/Start Sync.vi and b/tests/New_ATS/Tests/nested-oneof/Impl/Start Sync.vi differ diff --git a/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto b/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto index d9d0023c..f171e551 100644 --- a/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto +++ b/tests/New_ATS/Tests/nested-oneof/nested-oneof.proto @@ -23,6 +23,7 @@ message res { } message MessageA { + string anotherField = 3; oneof oneof_a { string data_a1 = 1; string data_a2 = 2; diff --git a/tests/New_ATS/Tests/nested-oneof/nested-oneof_client.py b/tests/New_ATS/Tests/nested-oneof/nested-oneof_client.py index ccd5c08d..f554d9fd 100644 --- a/tests/New_ATS/Tests/nested-oneof/nested-oneof_client.py +++ b/tests/New_ATS/Tests/nested-oneof/nested-oneof_client.py @@ -7,31 +7,42 @@ def get_GetFeature_output(test_input): req_id = test_input.get('req_id') - req_price = test_input['req_oneof'].get('req_price') - data_a1 = data_a2 = None + req_price = data_a1 = data_a2 = anotherField = None + if test_input['req_oneof'].get('req_price'): + req_price = test_input['req_oneof'].get('req_price') if test_input['req_oneof'].get('message_a'): - data_a1 = test_input['req_oneof'].get('message_a').get(data_a1) - data_a2 = test_input['req_oneof'].get('message_a').get(data_a2) + anotherField = test_input['req_oneof'].get('message_a').get('anotherField') + data_a1 = test_input['req_oneof'].get('message_a').get('oneof_a').get('data_a1') + data_a2 = test_input['req_oneof'].get('message_a').get('oneof_a').get('data_a2') with grpc.insecure_channel('localhost:50051') as channel: stub = nested_oneof_pb2_grpc.GreeterServiceStub(channel) request = nested_oneof_pb2.req() - request.req_id = 100 - # request.message_a.data_a1 = "Yash" - request.message_a.data_a2 = "Yash" - # request.req_price = req_price + request.req_id = req_id + if req_price != None: + request.req_price = req_price + if data_a1 != None: + request.message_a.data_a1 = data_a1 + if data_a2 != None: + request.message_a.data_a2 = data_a2 + if anotherField != None: + request.message_a.anotherField = anotherField + + print(request) response = stub.GetFeature(request) print(response) response_dict = {} response_dict['res_id'] = response.res_id - response_dict['res_oneof'] = {} + response_dict['res_oneof'] = {} if response.HasField('res_price'): response_dict['res_oneof']['res_price'] = response.res_price if response.HasField('message_a'): response_dict['res_oneof']['message_a'] = {} + response_dict['res_oneof']['message_a']['oneof_a'] = {} + response_dict['res_oneof']['message_a']['anotherField'] = response.message_a.anotherField if response.message_a.HasField('data_a1'): - response_dict['res_oneof']['message_a']['data_a1'] = response.message_a.data_a1 + response_dict['res_oneof']['message_a']['oneof_a']['data_a1'] = response.message_a.data_a1 if response.message_a.HasField('data_a2'): - response_dict['res_oneof']['message_a']['data_a2'] = response.message_a.data_a2 + response_dict['res_oneof']['message_a']['oneof_a']['data_a2'] = response.message_a.data_a2 return(response_dict) def read_json(filepath): @@ -48,6 +59,5 @@ def test_SayHello(testcase): assert get_GetFeature_output(test_input) == expected if __name__ == "__main__": - # response = get_GetFeature_output({"req_id":100, "req_oneof":{"req_price":20.06}}) - response = get_GetFeature_output({"req_id":100, "req_oneof":{"message_a":{"data_a1":"Yash"}}}) + response = get_GetFeature_output({'req_id': 561, 'req_oneof': {'message_a': {'anotherField': 'JustAnotherField', 'oneof_a': {'data_a2': 'Ankush'}}}}) print(response) \ No newline at end of file diff --git a/tests/New_ATS/Tests/nested-oneof/testcases/GetFeature.json b/tests/New_ATS/Tests/nested-oneof/testcases/GetFeature.json index 818b3d13..8cd23f05 100644 --- a/tests/New_ATS/Tests/nested-oneof/testcases/GetFeature.json +++ b/tests/New_ATS/Tests/nested-oneof/testcases/GetFeature.json @@ -20,7 +20,8 @@ "message_a": { "oneof_a": { "data_a1": "Yash" - } + }, + "anotherField": "bleh" } } }, @@ -30,7 +31,8 @@ "message_a": { "oneof_a": { "data_a1": "Yash_response" - } + }, + "anotherField": "bleh_response" } } } @@ -42,7 +44,8 @@ "message_a": { "oneof_a": { "data_a2": "Ankush" - } + }, + "anotherField": "bleh" } } }, @@ -52,7 +55,8 @@ "message_a": { "oneof_a": { "data_a2": "Ankush_response" - } + }, + "anotherField": "bleh_response" } } } diff --git a/tests/New_ATS/pylib/run_tests.py b/tests/New_ATS/pylib/run_tests.py index 5b479bea..6301b130 100644 --- a/tests/New_ATS/pylib/run_tests.py +++ b/tests/New_ATS/pylib/run_tests.py @@ -57,17 +57,26 @@ def run_test(test_config): check_for_pre_requisites(test_config) # 2. Generate the server + print ("Generating server code for " + test_config['test_name']) generate_server(test_config) # 3. Copy the 'Run Service.vi' from the Impl folder to the Generated_server folder run_service_impl_path = test_config['impl'] / 'Run Service.vi' run_service_gen_path = test_config['generated_server'] / 'Run Service.vi' - shutil.copyfile(run_service_impl_path, run_service_gen_path) + if pathlib.Path(test_config['generated_server']).exists(): + print (f"Copying 'Run Service.vi' to {run_service_gen_path}") + shutil.copyfile(run_service_impl_path, run_service_gen_path) + else: + print (f"{test_config['generated_server']} not generated") # 4. Copy the 'Start Sync.vi' from the Impl folder to the "Generated_server/RPC Service/GreeterService/Server API" folder start_sync_impl_path = test_config['impl'] / 'Start Sync.vi' start_sync_gen_path = test_config['generated_server'] / 'RPC Service' / 'GreeterService' / 'Server API' / 'Start Sync.vi' - shutil.copyfile(start_sync_impl_path, start_sync_gen_path) + if pathlib.Path(test_config['generated_server']).exists(): + print (f"Copying 'Start Sync.vi' to {start_sync_gen_path}") + shutil.copyfile(start_sync_impl_path, start_sync_gen_path) + else: + print (f"{test_config['generated_server']} not generated") # 5. Quit LabVIEW if it is running run_command(['taskkill', '/f', '/im', 'labview.exe']) @@ -86,6 +95,7 @@ def run_test(test_config): ]) # TODO Check whether labviewCLI is installed or not before running the command + print ("Running the server on the LabVIEW side") run_command(CLI_command) # 7. Create python virtual environment @@ -94,7 +104,7 @@ def run_test(test_config): ]) run_command(CLI_command) - # 7. Generate python grpc classes + # 8. Generate python grpc classes generate_command = ' '.join([ f"{test_config['python_path']} -m grpc_tools.protoc", f"--proto_path={test_config['test_folder']}", @@ -103,23 +113,25 @@ def run_test(test_config): f"--grpc_python_out={test_config['test_folder']}", f"{test_config['test_name']}.proto" ]) + print ("Compiling proto file") run_command(generate_command) - # 8. Call the TestServer() from test_folder/test_name_client.py + # 9. Call the TestServer() from test_folder/test_name_client.py and get the return value client_py_path = test_config['test_folder'] / str(test_config['test_name'] + '_client.py') run_client_command = ' '.join([ str(test_config['test_suite_folder'] / 'RunPythonClient.bat'), str(client_py_path), test_config['test_name'] ]) + print ("Running python client") output = run_command(run_client_command) print(output) FAILED += count_failed_testcases(output) - # 8. Quit LabVIEW if it is running + # 10. Quit LabVIEW if it is running run_command(['taskkill', '/f', '/im', 'labview.exe']) - # 9. Delete python grpc generated files + # 10. Delete python grpc generated files # for filename in os.listdir(test_config['test_folder']): # if "pb2" in filename: # os.remove(test_config['test_folder'] / filename) diff --git a/tests/New_ATS/pylib/testlist.json b/tests/New_ATS/pylib/testlist.json index 5f7c9d5f..ad25c141 100644 --- a/tests/New_ATS/pylib/testlist.json +++ b/tests/New_ATS/pylib/testlist.json @@ -1,8 +1,8 @@ [ { - "name": ["helloworld"], + "name": ["enum-oneof", "helloworld", "message-oneof", "multiple-field-oneof", "nested-oneof", "sibling-oneof", "simple-oneof"], "gen_type": "0", "labview_version": "2019", "labview_bitness": "32" } -] +] \ No newline at end of file