diff --git a/test/access_node/arbor/arbor_config.py b/test/access_node/arbor/arbor_config.py index bb2c78b7b6d7c51fe1f7ca6fac91e02ef6780399..cdae73bea68f3b136823628ef9f10e925194a5cf 100644 --- a/test/access_node/arbor/arbor_config.py +++ b/test/access_node/arbor/arbor_config.py @@ -6,7 +6,7 @@ BASE_REQUEST_URL = "http://insite-access-node:52056/arbor" #Relates every value to its corresponding name in the spike-data JSON-field class JSON_VALUE_TO_FIELD_NAME(Enum): simulationTimes = "simulationTimes" - nodeIds = "gIds" + gIds = "gIds" spikerecorderId = "spikerecorderId" spikerecorders = "spikerecorders" spikes = "spikes" @@ -14,3 +14,28 @@ class JSON_VALUE_TO_FIELD_NAME(Enum): simulationId = "simId" nodeCollections = "nodeCollections" kernelStatuses = "kernelStatuses" + probeData = "probeData" + probeKind = "probeKind" + cellInfos = "CellInfos" + probes = "probes" + globalProbeIndex = "globalProbeIndex" + cells = "cells" + cellGid = "cellGid" + cellLid = "cellLid" + sourceIndex = "sourceIndex" + cellDescription = "cellDescription" + gid = "gid" + lid = "lid" + cellKind = "cellKind" + numBranches = "numBranches" + numSegments = "numSegments" + size = "size" + time = "time" + data = "data" + morphology = "morphology" + label = "label" + decor = "decor" + location = "location" + hash = "hash" + toTime = "toTime" + fromTime = "fromTime" diff --git a/test/access_node/arbor/arbor_general_test_functions.py b/test/access_node/arbor/arbor_general_test_functions.py index a8ceb06e206a3e6aac979fa3a1c90dfb9b17a5d7..33d3611f3a2da2574c51947abd30e663fcc1473a 100644 --- a/test/access_node/arbor/arbor_general_test_functions.py +++ b/test/access_node/arbor/arbor_general_test_functions.py @@ -18,7 +18,7 @@ def return_json_body_if_status_ok(request): #Converts the given spike data to pairs out of nodeId and corresponding simulation times def zip_spikes(spikes): - return zip(spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value], spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value]) + return zip(spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value], spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value]) #Checks if the given spike data has a correct length, is sorted by time and does not include values smaller than zero def spikes_is_valid_format(spikes): @@ -36,23 +36,23 @@ def spikes_is_sorted_by_time(spikes): #Checks if nodeIds of the given spike data have the desired minimum def spikes_nodeIds_are_greater_or_equal_than(spikes, minimum): - for id in spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]: + for id in spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]: assert(id >= minimum) #Checks if the length of the two given spike-data sets is equal and if exactly the two wanted data-sets are included def spikes_is_data_length_valid(spikes, canBeEmpty = False): assert(JSON_VALUE_TO_FIELD_NAME.simulationTimes.value in spikes) - assert(JSON_VALUE_TO_FIELD_NAME.nodeIds.value in spikes) + assert(JSON_VALUE_TO_FIELD_NAME.gIds.value in spikes) assert(len(spikes.keys()) == 2) - assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]) == len(spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value])) + assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]) == len(spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value])) if not canBeEmpty: - assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]) > 0) + assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]) > 0) #Checks and returns whether the two given spike data-sets are equal def spikes_is_data_equal(spike_data_a, spike_data_b): spike_data_a[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] == spike_data_b[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] - spike_data_a[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] == spike_data_b[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] + spike_data_a[JSON_VALUE_TO_FIELD_NAME.gIds.value] == spike_data_b[JSON_VALUE_TO_FIELD_NAME.gIds.value] #Checks if the given simulation times are all greater than the desired time def spikes_simulation_times_are_greater_or_equal_than(spikes, minimum_time): @@ -66,18 +66,18 @@ def spikes_simulation_times_are_smaller_or_equal_than(spikes, maximum_time): #Checks if the given spike-data only includes the desired nodeIDs def spikes_nodeIds_are_subset(spikes, nodeId_list): - for id in spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]: + for id in spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]: assert(id in nodeId_list) #Checks if the given skipped spikes have the desired offset in comparison to the given unskipped spikes def spikes_has_offset(skipped_spikes, non_skipped_spikes, skip): - assert(len(skipped_spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]) + skip == len(non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value])) + assert(len(skipped_spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]) + skip == len(non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value])) assert(len(skipped_spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value]) + skip == len(non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value])) - skipped_nodeIds = non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value][skip::] + skipped_nodeIds = non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value][skip::] skipped_simulationTimes = non_skipped_spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value][skip::] - assert(skipped_nodeIds == skipped_spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]) + assert(skipped_nodeIds == skipped_spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]) assert(skipped_simulationTimes == skipped_spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value]) #Receives an list of spikes as input that was queried with the offset set to a value > 0. @@ -97,7 +97,7 @@ def spikes_has_offset_in_comparison_to(REQUEST_URL, skipped_spikes, PARAMETER_NA startIndex = nest_get_spikes_query_parameters[3] endIndex = nest_get_spikes_query_parameters[3] + nest_get_spikes_query_parameters[4] - spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.nodeIds.value][startIndex:endIndex] + spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.gIds.value] = spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.gIds.value][startIndex:endIndex] spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = spikes_no_skip_no_top[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value][startIndex:endIndex] spikes_has_offset(skipped_spikes, spikes_no_skip_no_top, 0) @@ -113,7 +113,7 @@ def spikes_has_offset_in_comparison_to(REQUEST_URL, skipped_spikes, PARAMETER_NA #Checks if the length of the given spike-data is less or equal to the maximum_number #Returns true if this is the case, false otherwise def spikes_length_less_or_equal_to(spikes, maximum_number): - assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value]) <= maximum_number) + assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value]) <= maximum_number) assert(len(spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value]) <= maximum_number) #Filters and returns the given spike data by deleting every entrie with a simulation time higher than the minimum time @@ -128,7 +128,7 @@ def get_spikes_with_minimum_time(spikes, minimum_time): filtered_nodes.append(node_id) spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = filtered_times - spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = filtered_nodes + spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value] = filtered_nodes return spikes @@ -144,7 +144,7 @@ def get_spikes_with_maximum_time(spikes, maximum_time): filtered_nodes.append(node_id) spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = filtered_times - spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = filtered_nodes + spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value] = filtered_nodes return spikes @@ -160,7 +160,7 @@ def get_spikes_with_nodeIds(spikes, nodeIds): filtered_nodes.append(node_id) spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = filtered_times - spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = filtered_nodes + spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value] = filtered_nodes return spikes @@ -179,7 +179,7 @@ def get_offset_spike_data(spikes, offset): count = count + 1 spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = filtered_times - spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = filtered_nodes + spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value] = filtered_nodes return spikes @@ -198,7 +198,7 @@ def get_top_spike_data(spikes, max_number): count = count + 1 spikes[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] = filtered_times - spikes[JSON_VALUE_TO_FIELD_NAME.nodeIds.value] = filtered_nodes + spikes[JSON_VALUE_TO_FIELD_NAME.gIds.value] = filtered_nodes return spikes diff --git a/test/access_node/arbor/test_arbor_get_cell_infos.py b/test/access_node/arbor/test_arbor_get_cell_infos.py new file mode 100644 index 0000000000000000000000000000000000000000..35037bcf7287b43e073d8b455c72d7a5e882bfd6 --- /dev/null +++ b/test/access_node/arbor/test_arbor_get_cell_infos.py @@ -0,0 +1,32 @@ +from arbor_general_test_functions import * +import pytest + +#URL used for the "nest_get_spikes" HTTP-query +URL_NEST_GET_CELL_INFOS = BASE_REQUEST_URL + "/cell_infos/" +#TODO: Fix inconsistency between plural and singular regarding "cell_info(s)" + +#Names for the "nest_get_spikes" request-parameters +class NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST (Enum): + gId = "gId" + +def cell_infos_is_valid_format(cell_object): + assert(JSON_VALUE_TO_FIELD_NAME.cellInfos.value in cell_object) + cell_infos = cell_object[JSON_VALUE_TO_FIELD_NAME.cellInfos.value] + + assert(len(cell_infos) != 0) + for cell_info in cell_infos: + assert(JSON_VALUE_TO_FIELD_NAME.gid.value in cell_info) + assert(isinstance(cell_info[JSON_VALUE_TO_FIELD_NAME.gid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.cellKind.value in cell_info) + assert(isinstance(cell_info[JSON_VALUE_TO_FIELD_NAME.cellKind.value], str)) + + assert(JSON_VALUE_TO_FIELD_NAME.numBranches.value in cell_info) + assert(isinstance(cell_info[JSON_VALUE_TO_FIELD_NAME.numBranches.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.numSegments.value in cell_info) + assert(isinstance(cell_info[JSON_VALUE_TO_FIELD_NAME.numSegments.value], int)) + +#Tests a default nest_get_spikes request without any parameters +def test_nest_get_cell_info_no_parameters(): + cell_infos_is_valid_format(return_json_body_if_status_ok(URL_NEST_GET_CELL_INFOS)) diff --git a/test/access_node/arbor/test_arbor_get_cells.py b/test/access_node/arbor/test_arbor_get_cells.py new file mode 100644 index 0000000000000000000000000000000000000000..57f7a39758b46a4ac03c37ced3362280a1bfa5f3 --- /dev/null +++ b/test/access_node/arbor/test_arbor_get_cells.py @@ -0,0 +1,41 @@ +from arbor_general_test_functions import * +import pytest + +#URL used for the "nest_get_spikes" HTTP-query +URL_NEST_GET_CELLS = BASE_REQUEST_URL + "/cells/" + +#Names for the "nest_get_spikes" request-parameters +class NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST (Enum): + gId = "gID" + lId = "lId" + pId = "pId" + uId = "uId" + hash = "hash" + +def cells_is_valid_format(cell_object): + assert(JSON_VALUE_TO_FIELD_NAME.cells.value in cell_object) + cells = cell_object[JSON_VALUE_TO_FIELD_NAME.cells.value] + + assert(len(cells) != 0) + for cell in cells: + assert(JSON_VALUE_TO_FIELD_NAME.gid.value in cell) + assert(isinstance(cell[JSON_VALUE_TO_FIELD_NAME.gid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.cellKind.value in cell) + assert(isinstance(cell[JSON_VALUE_TO_FIELD_NAME.cellKind.value], str)) + + assert(JSON_VALUE_TO_FIELD_NAME.cellDescription.value in cell) + + description = cell[JSON_VALUE_TO_FIELD_NAME.cellDescription.value] + assert(len(description) > 0) + + assert(JSON_VALUE_TO_FIELD_NAME.morphology.value in description) + + assert(JSON_VALUE_TO_FIELD_NAME.label.value in description) + + assert(JSON_VALUE_TO_FIELD_NAME.decor.value in description) + + +#Tests a default nest_get_spikes request without any parameters +def test_nest_get_cells_no_parameters(): + cells_is_valid_format(return_json_body_if_status_ok(URL_NEST_GET_CELLS)) diff --git a/test/access_node/arbor/test_arbor_get_probe_data.py b/test/access_node/arbor/test_arbor_get_probe_data.py new file mode 100644 index 0000000000000000000000000000000000000000..57d91af277bbe68a95d9737abd772b409afde90b --- /dev/null +++ b/test/access_node/arbor/test_arbor_get_probe_data.py @@ -0,0 +1,143 @@ +from arbor_general_test_functions import * +import pytest + +URL_NEST_GET_PROBE_DATA = BASE_REQUEST_URL + "/probe_data/" + +class NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST (Enum): + #TODO: make "x_id_" and "xId" consistent between json and params + gId = "gId" + lId = "lId" + pId = "pId" + fromTime = "fromTime" + toTime = "toTime" + +def probe_data_is_valid_format(probes_object): + assert(JSON_VALUE_TO_FIELD_NAME.probeData.value in probes_object) + probe_data = probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + #TODO: make "probeData" and "probe_data" consistent + + assert(len(probe_data) != 0) + for probe_date in probe_data: + assert(JSON_VALUE_TO_FIELD_NAME.gid.value in probe_date) + assert(isinstance(probe_date[JSON_VALUE_TO_FIELD_NAME.gid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.lid.value in probe_date) + assert(isinstance(probe_date[JSON_VALUE_TO_FIELD_NAME.lid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.sourceIndex.value in probe_date) + assert(isinstance(probe_date[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.size.value in probe_date) + assert(isinstance(probe_date[JSON_VALUE_TO_FIELD_NAME.size.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.simulationTimes.value in probe_date) + times = probe_date[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] + assert(len(times) > 0) + + assert(JSON_VALUE_TO_FIELD_NAME.gIds.value in probe_date) + data = probe_date[JSON_VALUE_TO_FIELD_NAME.gIds.value] + assert(len(data) > 0) + +#Tests a request without any parameters +def test_nest_get_probes_no_parameters(): + probe_data_is_valid_format(return_json_body_if_status_ok(URL_NEST_GET_PROBE_DATA)) + +def test_nest_get_probe_data_parameter_gId(): + parameter_values = [2, 1, 1, 20, 80] + parameter_set_combination = [True, False, False, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.gid.value] == parameter_values[0]) + +def test_nest_get_probe_data_parameter_lId(): + parameter_values = [2, 1, 1, 20, 80] + parameter_set_combination = [False, True, False, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.lid.value] == parameter_values[1]) + +def test_nest_get_probe_data_parameter_pId(): + parameter_values = [2, 1, 1, 20, 80] + parameter_set_combination = [False, False, True, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value] == parameter_values[2]) + +def test_nest_get_probe_data_parameter_fromTime(): + parameter_values = [2, 1, 1, 20, 80] + parameter_set_combination = [False, False, False, True, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + for probe_date in probe_data: + simTimes = probe_date[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] + for t in simTimes: + assert(t >= parameter_values[3]) + +def test_nest_get_probe_data_parameter_toTime(): + parameter_values = [2, 1, 1, 20, 80] + parameter_set_combination = [False, False, False, False, True] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + for probe_date in probe_data: + simTimes = probe_date[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] + for t in simTimes: + assert(t <= parameter_values[4]) + +def test_nest_get_probe_data_all_parameters(): + parameter_values = [2, 1, 0, 20, 80] + parameter_set_combination = [True, True, True, True, True] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBE_DATA, NEST_GET_PROBE_DATA_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probe_data_is_valid_format(filtered_probes_object) + + probe_data = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probeData.value] + + assert(len(probe_data) > 0) + + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.gid.value] == parameter_values[0]) + + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.lid.value] == parameter_values[1]) + + for probe_date in probe_data: + simTimes = probe_date[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] + for t in simTimes: + assert(t >= parameter_values[3]) + + for probe_date in probe_data: + assert(probe_date[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value] == parameter_values[2]) + + for probe_date in probe_data: + simTimes = probe_date[JSON_VALUE_TO_FIELD_NAME.simulationTimes.value] + for t in simTimes: + assert(t <= parameter_values[4]) diff --git a/test/access_node/arbor/test_arbor_get_probes.py b/test/access_node/arbor/test_arbor_get_probes.py new file mode 100644 index 0000000000000000000000000000000000000000..4f01ee8a15e652c926a9115ae3504586d7a8262e --- /dev/null +++ b/test/access_node/arbor/test_arbor_get_probes.py @@ -0,0 +1,126 @@ +from arbor_general_test_functions import * +import pytest + +#URL used for the arbor HTTP-query +URL_NEST_GET_PROBES = BASE_REQUEST_URL + "/probes/" + +#Names for the arbor request-parameters +class NEST_GET_PROBES_PARAMETER_NAME_LIST (Enum): + gId = "gId" + lId = "lId" + pId = "pId" + #TODO: Rename pId to source_index or unify otherwise + uId = "uId" + #TODO: Rename uId to probe_global_index or unify otherwise + hash = "hash" + +def probes_is_valid_format(probes_object): + assert(JSON_VALUE_TO_FIELD_NAME.probes.value in probes_object) + probes = probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) != 0) + for probe in probes: + assert(JSON_VALUE_TO_FIELD_NAME.cellGid.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.cellGid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.cellLid.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.cellLid.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.sourceIndex.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.probeKind.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.probeKind.value], str)) + + assert(JSON_VALUE_TO_FIELD_NAME.hash.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.hash.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.globalProbeIndex.value in probe) + assert(isinstance(probe[JSON_VALUE_TO_FIELD_NAME.globalProbeIndex.value], int)) + + assert(JSON_VALUE_TO_FIELD_NAME.location.value in probe) + +def test_nest_get_probes_no_parameters(): + probes_is_valid_format(return_json_body_if_status_ok(URL_NEST_GET_PROBES)) + +def test_nest_get_probes_parameter_gId(): + parameter_values = [2, 1, 1, 0, 4294967298] + parameter_set_combination = [True, False, False, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) != 0) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.cellGid.value] == parameter_values[0]) + +def test_nest_get_probes_parameter_lId(): + parameter_values = [2, 1, 1, 0, 4294967298] + parameter_set_combination = [False, True, False, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) != 0) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.cellLid.value] == parameter_values[1]) + +def test_nest_get_probes_parameter_pId(): + parameter_values = [2, 1, 1, 0, 4294967298] + parameter_set_combination = [False, False, True, False, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) != 0) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value] == parameter_values[2]) + +def test_nest_get_probes_parameter_uId(): + parameter_values = [2, 1, 1, 7, 4294967298] + parameter_set_combination = [False, False, False, True, False] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) == 1) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.globalProbeIndex.value] == parameter_values[3]) + +def test_nest_get_probes_parameter_hash(): + parameter_values = [2, 1, 1, 7, 4294967298] + parameter_set_combination = [False, False, False, False, True] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) == 1) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.hash.value] == parameter_values[4]) + +def test_nest_get_probes_all_parameters(): + parameter_values = [0, 1, 0, 3, 4294967296] + parameter_set_combination = [True, True, True, True, True] + + filtered_probes_object = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_PROBES, NEST_GET_PROBES_PARAMETER_NAME_LIST, parameter_values, parameter_set_combination)) + probes_is_valid_format(filtered_probes_object) + + probes = filtered_probes_object[JSON_VALUE_TO_FIELD_NAME.probes.value] + + assert(len(probes) == 1) + for probe in probes: + assert(probe[JSON_VALUE_TO_FIELD_NAME.cellGid.value] == parameter_values[0]) + assert(probe[JSON_VALUE_TO_FIELD_NAME.cellLid.value] == parameter_values[1]) + assert(probe[JSON_VALUE_TO_FIELD_NAME.sourceIndex.value] == parameter_values[2]) + assert(probe[JSON_VALUE_TO_FIELD_NAME.globalProbeIndex.value] == parameter_values[3]) + assert(probe[JSON_VALUE_TO_FIELD_NAME.hash.value] == parameter_values[4]) diff --git a/test/access_node/arbor/test_arbor_get_spikes.py b/test/access_node/arbor/test_arbor_get_spikes.py index 6db8999b6d6c426a70355577805e4647ab30ae03..5075efd1b860e05795b9ce7cea5110a86249d997 100644 --- a/test/access_node/arbor/test_arbor_get_spikes.py +++ b/test/access_node/arbor/test_arbor_get_spikes.py @@ -8,7 +8,7 @@ URL_NEST_GET_SPIKES = BASE_REQUEST_URL + "/spikes/" class NEST_GET_SPIKES_PARAMETER_NAME_LIST (Enum): fromTime = "fromTime" toTime = "toTime" - nodeIds = "gId" + gId = "gId" skip = "skip" top = "top" @@ -80,7 +80,6 @@ def test_nest_get_spikes_parameter_top(): spikes_length_less_or_equal_to(filtered_spikes, parameter_values[4]) #Tests a nest_get_spikes request with the paramaters: "fromTime", "toTime", "nodeIds", "skip" and "top" by checking if the conditions for each of the parameters apply to the returned data -@pytest.mark.order(after="test_order.py::test_sim_finished") def test_nest_get_spikes_all_parameters(): paramater_values = [ 2, @@ -100,7 +99,6 @@ def test_nest_get_spikes_all_parameters(): spikes_length_less_or_equal_to(filtered_spikes, paramater_values[4]) #Tests every possible combination of the nest_get_spikes query-parameters "fromTime", "toTime", "nodeIds", "skip" and "top" by checking if the conditions for each of the parameters apply to the returned data -@pytest.mark.order(after="test_order.py::test_sim_finished") def test_nest_get_spikes_parameter_combinations(): paramater_values = [ 2, @@ -111,24 +109,3 @@ def test_nest_get_spikes_parameter_combinations(): ] check_all_parameter_combinations(URL_NEST_GET_SPIKES, NEST_GET_SPIKES_PARAMETER_NAME_LIST, paramater_values) - -#@pytest.mark.order(after="test_order.py::test_sim_finished") -#def test_nest_get_spikes_last_frame_sim_finished(): -# end_time = return_json_body_if_status_ok(BASE_REQUEST_URL + '/simulationTimeInfo')['end'] -# -# spikes_without_last = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_SPIKES,[NEST_GET_SPIKES_PARAMETER_NAME_LIST.toTime],[end_time - 1.0])) -# assert(spikes_without_last['lastFrame'] == 0) -# -# spikes_without_last = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_SPIKES)) -# assert(spikes_without_last['lastFrame'] == 1) -# -#@pytest.mark.order("first") -#def test_nest_get_spikes_last_frame_while_running(nest_simulation,printer): -# simulation_time_info = return_json_body_if_status_ok(BASE_REQUEST_URL + '/simulationTimeInfo') -# end_time = simulation_time_info['end'] -# curr_time = simulation_time_info['current'] -# if curr_time == end_time: -# return -# -# spikes_without_last = return_json_body_if_status_ok(build_query_string(URL_NEST_GET_SPIKES)) -# assert(spikes_without_last['lastFrame'] == False)