|
1012 | 1012 | }, |
1013 | 1013 | "response": [] |
1014 | 1014 | }, |
| 1015 | + { |
| 1016 | + "name": "Update Flight Rocket", |
| 1017 | + "event": [ |
| 1018 | + { |
| 1019 | + "listen": "test", |
| 1020 | + "script": { |
| 1021 | + "id": "faf35bda-1c3b-4478-a523-8f801c2f8a11", |
| 1022 | + "exec": [ |
| 1023 | + "//Fixes the issue of breaking the collection runner whenever an http 500 is received", |
| 1024 | + "if (responseCode.code == 500) {", |
| 1025 | + " pm.test(\"Given a request is made then response must return a 200 status code\", function () {", |
| 1026 | + " pm.expect(responseCode.code).to.eql(200);", |
| 1027 | + " });", |
| 1028 | + " return", |
| 1029 | + "}", |
| 1030 | + "", |
| 1031 | + "var apiRspn = pm.response.json();", |
| 1032 | + "var flightRequest = JSON.parse(pm.request.body.raw);", |
| 1033 | + "", |
| 1034 | + "// reduce environment date for future assertion", |
| 1035 | + "flightRequest.environment.date = flightRequest.environment.date.substring(0, flightRequest.environment.date.length - 7);", |
| 1036 | + "", |
| 1037 | + "// save new flight id", |
| 1038 | + "pm.environment.set('flight_id', apiRspn.new_flight_id) ", |
| 1039 | + "", |
| 1040 | + "// save rocket parameters", |
| 1041 | + "pm.environment.set('rocket_id', apiRspn.new_rocket_id)", |
| 1042 | + "pm.environment.set('radius', flightRequest.radius)", |
| 1043 | + "pm.environment.set('mass', flightRequest.mass)", |
| 1044 | + "pm.environment.set('inertia', flightRequest.inertia)", |
| 1045 | + "pm.environment.set('power_off_drag', flightRequest.power_off_drag)", |
| 1046 | + "pm.environment.set('power_on_drag', flightRequest.power_on_drag)", |
| 1047 | + "pm.environment.set('center_of_mass_without_motor', flightRequest.center_of_mass_without_motor)", |
| 1048 | + "pm.environment.set('motor_position', flightRequest.motor_position)", |
| 1049 | + "pm.environment.set('rail_buttons', flightRequest.rail_buttons)", |
| 1050 | + "pm.environment.set('upper_button_position', flightRequest.rail_buttons.upper_button_position)", |
| 1051 | + "pm.environment.set('lower_button_position', flightRequest.rail_buttons.lower_button_position)", |
| 1052 | + "pm.environment.set('angular_position', flightRequest.rail_buttons.angular_position)", |
| 1053 | + "pm.environment.set('rocket_coordinate_system_orientation', flightRequest.coordinate_system_orientation)", |
| 1054 | + "", |
| 1055 | + "// rocket motor", |
| 1056 | + "pm.environment.set('burn_time', flightRequest.motor.burn_time)", |
| 1057 | + "pm.environment.set('dry_mass', flightRequest.motor.dry_mass)", |
| 1058 | + "pm.environment.set('dry_inertia', flightRequest.motor.dry_inertia)", |
| 1059 | + "pm.environment.set('center_of_dry_mass_position', flightRequest.motor.center_of_dry_mass_position)", |
| 1060 | + "pm.environment.set('grain_number', flightRequest.motor.grain_number)", |
| 1061 | + "pm.environment.set('grain_density', flightRequest.motor.grain_density)", |
| 1062 | + "pm.environment.set('grain_outer_radius', flightRequest.motor.grain_outer_radius)", |
| 1063 | + "pm.environment.set('grain_initial_inner_radius', flightRequest.motor.grain_initial_inner_radius)", |
| 1064 | + "pm.environment.set('grain_initial_height', flightRequest.motor.grain_initial_height)", |
| 1065 | + "pm.environment.set('grains_center_of_mass_position', flightRequest.motor.grains_center_of_mass_position)", |
| 1066 | + "pm.environment.set('grain_separation', flightRequest.motor.grain_separation)", |
| 1067 | + "pm.environment.set('thrust_source', flightRequest.motor.thrust_source)", |
| 1068 | + "pm.environment.set('nozzle_radius', flightRequest.motor.nozzle_radius)", |
| 1069 | + "pm.environment.set('throat_radius', flightRequest.motor.throat_radius)", |
| 1070 | + "pm.environment.set('interpolation_method', flightRequest.motor.interpolation_method)", |
| 1071 | + "pm.environment.set('motor_coordinate_system_orientation', flightRequest.motor.coordinate_system_orientation)", |
| 1072 | + "", |
| 1073 | + "// rocket nose", |
| 1074 | + "pm.environment.set('nose_length', flightRequest.nose.length)", |
| 1075 | + "pm.environment.set('kind', flightRequest.nose.kind)", |
| 1076 | + "pm.environment.set('nose_position', flightRequest.nose.position)", |
| 1077 | + "pm.environment.set('base_radius', flightRequest.nose.base_radius)", |
| 1078 | + "pm.environment.set('rocket_radius', flightRequest.nose.rocket_radius)", |
| 1079 | + "", |
| 1080 | + "// rocket fins", |
| 1081 | + "pm.environment.set('n', flightRequest.fins.n)", |
| 1082 | + "pm.environment.set('root_chord', flightRequest.fins.root_chord)", |
| 1083 | + "pm.environment.set('tip_chord', flightRequest.fins.tip_chord)", |
| 1084 | + "pm.environment.set('span', flightRequest.fins.span)", |
| 1085 | + "pm.environment.set('fin_position', flightRequest.fins.position)", |
| 1086 | + "pm.environment.set('cant_angle', flightRequest.fins.cant_angle)", |
| 1087 | + "pm.environment.set('fin_radius', flightRequest.fins.radius)", |
| 1088 | + "pm.environment.set('airfoil', flightRequest.fins.airfoil)", |
| 1089 | + "", |
| 1090 | + "// rocket tail", |
| 1091 | + "pm.environment.set('top_radius', flightRequest.tail.top_radius)", |
| 1092 | + "pm.environment.set('bottom_radius', flightRequest.tail.bottom_radius)", |
| 1093 | + "pm.environment.set('tail_length', flightRequest.tail.length)", |
| 1094 | + "pm.environment.set('tail_position', flightRequest.tail.position)", |
| 1095 | + "pm.environment.set('tail_radius', flightRequest.tail.radius)", |
| 1096 | + "", |
| 1097 | + "// rocket parachute", |
| 1098 | + "pm.environment.set('parachutes_names', flightRequest.parachutes.name)", |
| 1099 | + "pm.environment.set('parachutes_cds', flightRequest.parachutes.cd_s)", |
| 1100 | + "pm.environment.set('parachutes_sampling_rate', flightRequest.parachutes.sampling_rate)", |
| 1101 | + "pm.environment.set('parachutes_lags', flightRequest.parachutes.lag)", |
| 1102 | + "pm.environment.set('parachutes_noises', flightRequest.parachutes.noise)", |
| 1103 | + "pm.environment.set('parachutes_triggers', flightRequest.parachutes.triggers)", |
| 1104 | + "", |
| 1105 | + "//TEST", |
| 1106 | + "bdd = \"Given a valid Flight PUT request is made to the API\";", |
| 1107 | + " pm.test(bdd + \" then response must return a 200 status code\", function () {", |
| 1108 | + " pm.expect(responseCode.code).to.eql(200);", |
| 1109 | + " });", |
| 1110 | + " pm.test(bdd + \" then response must contain a valid message\", function () {", |
| 1111 | + " pm.expect(apiRspn.message).to.eql(\"Flight successfully updated\");", |
| 1112 | + " });", |
| 1113 | + " pm.test(bdd + \" then response must contain a valid new_flight_id\", function () {", |
| 1114 | + " pm.expect(apiRspn.new_flight_id).to.exist; ", |
| 1115 | + " });" |
| 1116 | + ], |
| 1117 | + "type": "text/javascript" |
| 1118 | + } |
| 1119 | + }, |
| 1120 | + { |
| 1121 | + "listen": "prerequest", |
| 1122 | + "script": { |
| 1123 | + "id": "c39c5aee-cdfc-4304-ae91-3a722d0fac98", |
| 1124 | + "exec": [ |
| 1125 | + "" |
| 1126 | + ], |
| 1127 | + "type": "text/javascript" |
| 1128 | + } |
| 1129 | + } |
| 1130 | + ], |
| 1131 | + "id": "194a4296-299e-4d76-ac19-2ff5761f7de6", |
| 1132 | + "protocolProfileBehavior": { |
| 1133 | + "disableBodyPruning": true |
| 1134 | + }, |
| 1135 | + "request": { |
| 1136 | + "method": "PUT", |
| 1137 | + "header": [], |
| 1138 | + "body": { |
| 1139 | + "mode": "raw", |
| 1140 | + "raw": "{\n \"radius\": 0.0632,\n \"mass\": 16.235,\n \"inertia\": [\n 6.321, \n 6.321, \n 0.0346\n ],\n \"power_off_drag\": \"lib/data/calisto/powerOffDragCurve.csv\",\n \"power_on_drag\": \"lib/data/calisto/powerOnDragCurve.csv\",\n \"center_of_mass_without_motor\": 0,\n \"coordinate_system_orientation\": \"tail_to_nose\",\n \"motor_position\": -1.255,\n \"rail_buttons\": {\n \"upper_button_position\": -0.5,\n \"lower_button_position\": 0.2,\n \"angular_position\": 45\n },\n \"motor\": {\n \"burn_time\": 3.9,\n \"dry_mass\": 1.815,\n \"dry_inertia\": [0.125, 0.125, 0.002],\n \"center_of_dry_mass_position\": 0.317,\n \"grain_number\": 5,\n \"grain_density\": 1815,\n \"grain_outer_radius\": 0.033,\n \"grain_initial_inner_radius\": 0.015,\n \"grain_initial_height\": 0.12,\n \"grains_center_of_mass_position\": -0.85704,\n \"grain_separation\": 0.005,\n \"thrust_source\": \"lib/data/motors/Cesaroni_M1670.eng\", \n \"nozzle_radius\": 0.033,\n \"throat_radius\": 0.011,\n \"interpolation_method\": \"linear\",\n \"coordinate_system_orientation\": \"nozzle_to_combustion_chamber\"\n },\n \"nose\": {\n \"length\": 0.55829,\n \"kind\": \"vonKarman\",\n \"position\": 1.278,\n \"base_radius\": 0.0635,\n \"rocket_radius\": 0.0635\n },\n \"fins\": {\n \"n\": 4,\n \"root_chord\": 0.12,\n \"tip_chord\": 0.04,\n \"span\": 0.1,\n \"position\": -1.04956,\n \"cant_angle\": 0,\n \"radius\": 0.0635,\n \"airfoil\": \"\"\n },\n \"tail\": {\n \"top_radius\": 0.0635,\n \"bottom_radius\": 0.0435,\n \"length\": 0.06,\n \"position\": -1.194656,\n \"radius\": 0.0635\n },\n \"parachutes\": {\n \"name\": [\n \"Main\",\n \"Drogue\"\n ],\n \"cd_s\": [\n 10,\n 1\n ],\n \"sampling_rate\": [\n 105,\n 105\n ],\n \"lag\": [\n 1.5,\n 1.5\n ],\n \"noise\": [\n [\n 0,\n 8.3,\n 0.5\n ],\n [\n 0,\n 8.3,\n 0.5\n ]\n ],\n \"triggers\": [\n \"lambda p, h, y: y[5] < 0 and h < 800\",\n \"lambda p, h, y: y[5] < 0\"\n ]\n } \n}", |
| 1141 | + "options": { |
| 1142 | + "raw": { |
| 1143 | + "language": "json" |
| 1144 | + } |
| 1145 | + } |
| 1146 | + }, |
| 1147 | + "url": "{{endpoint}}/flights/{{flight_id}}/rocket", |
| 1148 | + "description": "This returns a `token` that you can use to retrieve information later on.\n\nWe have included a test to confirm if a token is returned. We have also added test scripts to copy the token to the `token` collection variable. This makes it easy for us to reuse this token in other requests in the collection." |
| 1149 | + }, |
| 1150 | + "response": [] |
| 1151 | + }, |
1015 | 1152 | { |
1016 | 1153 | "name": "Delete Flight", |
1017 | 1154 | "event": [ |
|
0 commit comments