{"info":{"_postman_id":"f426775c-cd9d-4fea-90d6-ca8653a225a0","name":"SOS2021-09-performances-by-degrees-us-V2","description":"<html><head></head><body><h1 id=\"introduction\">Introduction</h1>\n<p>API que permite obtener el rendimiento en creditos de los alumnos de los diferentes centros de la US</p>\n<h1 id=\"error-codes\">Error Codes</h1>\n<p>Se sigue el modelo de REST API.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Introduction","slug":"introduction"},{"content":"Error Codes","slug":"error-codes"}],"owner":"15037183","collectionId":"f426775c-cd9d-4fea-90d6-ca8653a225a0","publishedId":"TzJsexSB","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2021-04-17T20:10:03.000Z"},"item":[{"name":"Get API info","event":[{"listen":"test","script":{"exec":["pm.test(\"Status code is 200\", function(){","    pm.response.to.have.status(200);","});","","pm.test(\"Content is OK\", function(){","    pm.response.to.have.body('<html><h3>performances-by-degrees-us</h3>Estudia el rendimiento de los alumnos comparando los créditos matriculados frente a los completados segun año y centro.<p></p><table class=\"table table-bordered table-hover table-condensed\"> <thead><tr><th title=\"Field #1\">field-of-knowledge</th> <th title=\"Field #2\">year</th> <th title=\"Field #3\">performance-percents</th> <th title=\"Field #4\">credits-passed</th> <th title=\"Field #5\">credits-enrolled</th> <th title=\"Field #6\">center</th> </tr></thead> <tbody><tr> <td>History</td> <td align=\"right\">2018</td> <td>83,44%</td> <td>2006</td> <td>2404</td> <td>FHISTRY</td> </tr> <tr> <td>Computer-Science</td> <td align=\"right\">2018</td> <td>87,10%</td> <td>1870</td> <td>2147</td> <td>ETSII</td> </tr> <tr> <td>Graography</td> <td align=\"right\">2018</td> <td>88,24%</td> <td>2010</td> <td>2278</td> <td>FHISTRY</td> </tr> <tr> <td>Art</td> <td align=\"right\">2018</td> <td>77,69%</td> <td>390</td> <td>502</td> <td>FBBAA</td> </tr> <tr> <td>Nursering</td> <td align=\"right\">2018</td> <td>87,93%</td> <td>1551</td> <td>1764</td> <td>FEFP</td> </tr> <tr> <td>Phychology</td> <td align=\"right\">2018</td> <td>83,21%</td> <td>2567,5</td> <td>3085,5</td> <td>FPSYCHOLOGY</td> </tr> <tr> <td>Engineering</td> <td align=\"right\">2018</td> <td>77,45%</td> <td>1882</td> <td>2430</td> <td>EPS</td> </tr> <tr> <td>Maths</td> <td align=\"right\">2018</td> <td>109,70%</td> <td>1188</td> <td>1083</td> <td>FMATHS</td> </tr> <tr> <td>Medicine</td> <td align=\"right\">2018</td> <td>74,45%</td> <td>1850</td> <td>2485</td> <td>FMEDICINE</td> </tr> </tbody></table></html>');","});"],"type":"text/javascript","id":"9a16e1c9-1e57-4efa-b916-8727ce88fb84"}}],"id":"781bb525-6a3b-4245-b978-f994dff93ccf","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:3000/info/performances-by-degrees-us","urlObject":{"path":["info","performances-by-degrees-us"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"781bb525-6a3b-4245-b978-f994dff93ccf"},{"name":"Load initial data","event":[{"listen":"test","script":{"id":"e49cc5ac-4ca2-430c-9537-9d36fd91bd7f","exec":["pm.test(\"Status Code\", function() {","    pm.expect(pm.response.code).to.be.oneOf([200, 201])","});"],"type":"text/javascript"}}],"id":"754246d7-f194-4167-a4fc-869579f54480","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/loadInitialData","urlObject":{"path":["api","v2","performances-by-degrees-us","loadInitialData"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"754246d7-f194-4167-a4fc-869579f54480"},{"name":"Search Data","event":[{"listen":"test","script":{"id":"dc1e8c5c-5540-4a2a-92e9-67d5227bbc41","exec":["pm.test(\"Status Code\", function() {","    pm.response.to.have.status(200);","});","","pm.test(\"Is not empty\", function(){","    pm.expect(pm.response.json().length).greaterThan(0);","});","","pm.test(\"Documents are valid\", function(){","    pm.expect(isValidData(pm.response.json())).equals(true);","});","","pm.sendRequest(pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/?limit=1\", function (err, response) {","    pm.test(\"Limit 1 document\", function(){","        pm.expect(response.json().length).equals(1);","    });","});","","pm.sendRequest(pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/?year=\" + pm.response.json()[0][\"year\"], function (err, response) {","    pm.test(\"Documents by year\", function(){","        let resp = response.json();","        let year = pm.response.json()[0][\"year\"];","        for(let element in resp){","            pm.expect(resp[element][\"year\"]).equals(year);","        }","    });","});","","function isValidData(d){","    if(!Array.isArray(d)) return validDataRow(d);","","    for(let element in d){","        if(!validDataRow(d[element])) return false;","    }","","    return true;","}","","function validDataRow(d){","    if(Object.keys(d).length !== 6) return false;","    if (!d[\"field-of-knowledge\"]) return false;","    if (!d.year) return false;","    if (!d[\"performance-percents\"]) return false;","    if (!d[\"credits-passed\"]) return false;","    if (!d[\"credits-enrolled\"]) return false;","    if (!d[\"center\"]) return false;","    return true;","}"],"type":"text/javascript"}}],"id":"cc148a34-5931-4f26-ba6a-73222be510e6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/","urlObject":{"path":["api","v2","performances-by-degrees-us",""],"host":["http://127.0.0.1:3000"],"query":[{"disabled":true,"key":"offset","value":"1"},{"disabled":true,"key":"limit","value":"1"},{"disabled":true,"key":"center","value":"ETSII"},{"disabled":true,"key":"credits-passed","value":"1870"},{"disabled":true,"key":"credits-enrolled","value":"2147"},{"disabled":true,"key":"field-of-knowledge","value":"Computer-Science"},{"disabled":true,"key":"year","value":"2018"}],"variable":[]}},"response":[],"_postman_id":"cc148a34-5931-4f26-ba6a-73222be510e6"},{"name":"Modify Record","event":[{"listen":"test","script":{"id":"951e2663-88c2-4669-bfea-27b20df0d4fc","exec":["pm.sendRequest({","    url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/\",","    method: 'POST',","    header: {","        'content-type': 'application/json'","    },","    body: {","        mode: 'raw',","        raw: JSON.stringify({ \"field-of-knowledge\": \"PruebaPOSTMAN2\", \"year\": 5555, \"performance-percents\": \"0\", \"credits-passed\": 1870, \"credits-enrolled\": 2147, \"center\": \"FHISTRY\" })","    }","}, function (err, res) {","            pm.sendRequest({","            url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/FHISTRY/5555/PruebaPOSTMAN2\",","            method: 'PUT',","            header: {","            'content-type': 'application/json'","            },","            body: {","                mode: 'raw',","                raw: JSON.stringify({ \"field-of-knowledge\": \"FuncionaPOSTMAN\", \"year\": 5555, \"performance-percents\": \"0\", \"credits-passed\": 1870, \"credits-enrolled\": 2147, \"center\": \"FHISTRY\" })","            }","        }, function (err, res) {","            pm.test(\"Modify one record\", function(){","                pm.expect(res.code).equals(200);","            });","        });","});","","pm.sendRequest({","    url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/FHISTRY/5555/PruebaPOSTMAN2\",","    method: 'PUT',","    header: {","    'content-type': 'application/json'","    },","    body: {","        mode: 'raw',","        raw: JSON.stringify({ \"field-of-knowledge\": \"FuncionaPOSTMAN\"})","    }","    }, function (err, res) {","    pm.test(\"Invalid modification\", function(){","        pm.expect(res.code).equals(400);","    });","});"],"type":"text/javascript"}}],"id":"93f635ca-764b-4399-bde1-36cd1d9e9f37","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PUT","header":[],"body":{"mode":"raw","raw":"{\n    \"field-of-knowledge\": \"Histor22y\",\n    \"year\": 2018,\n    \"performance-percents\": \"83.44%\",\n    \"credits-passed\": 2006,\n    \"credits-enrolled\": 2404,\n    \"center\": \"FHISTRY\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/FHISTRY/2018/History","urlObject":{"path":["api","v2","performances-by-degrees-us","FHISTRY","2018","History"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"93f635ca-764b-4399-bde1-36cd1d9e9f37"},{"name":"GET Record","event":[{"listen":"test","script":{"id":"da7d6299-0b5d-4c29-a02d-f3179444ac98","exec":["pm.test(\"Valid record\", function(){","    pm.expect(pm.response.code).equals(200);","});"],"type":"text/javascript"}}],"id":"3ff2f8ff-3e7b-41e3-9f56-1329f87800e8","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/ETSII/2018/Computer-Science","urlObject":{"path":["api","v2","performances-by-degrees-us","ETSII","2018","Computer-Science"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"3ff2f8ff-3e7b-41e3-9f56-1329f87800e8"},{"name":"Add Data","event":[{"listen":"test","script":{"id":"69b8bc23-f641-4637-89c7-415036231408","exec":["pm.test(\"Add element\", function(){","        pm.response.to.have.status(201);","});","","pm.sendRequest({","    url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/\",","    method: 'POST',","    header: {","        'content-type': 'application/json'","    },","    body: {","        mode: 'raw',","        raw: JSON.stringify({ year: 2055})","    }","}, function (err, res) {","    pm.test(\"Add invalid element\", function(){","            pm.expect(res.code).equals(400);","    });","});"],"type":"text/javascript"}}],"id":"29330867-6ab3-49ff-a862-920982e5fab5","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n        \"field-of-knowledge\": \"Prueba5\",\n        \"year\": 2019,\n        \"performance-percents\": \"87.10%\",\n        \"credits-passed\": 1870,\n        \"credits-enrolled\": 2147,\n        \"center\": \"FHISTRY\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/","urlObject":{"path":["api","v2","performances-by-degrees-us",""],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"29330867-6ab3-49ff-a862-920982e5fab5"},{"name":"PUT to collection (Invalid)","event":[{"listen":"test","script":{"id":"86e900f6-f595-4102-a318-bad0fd8a4394","exec":["pm.test(\"Status code is 405\", function(){","    pm.response.to.have.status(405);","});"],"type":"text/javascript"}}],"id":"c1bd15ca-fe93-4445-aeeb-f6bc3d86b545","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PUT","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/","urlObject":{"path":["api","v2","performances-by-degrees-us",""],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"c1bd15ca-fe93-4445-aeeb-f6bc3d86b545"},{"name":"POST to element (Invalid)","event":[{"listen":"test","script":{"id":"3368c3cc-8815-4120-85cb-6fbda707bb9f","exec":["pm.test(\"Status code is 405\", function(){","    pm.response.to.have.status(405);","});"],"type":"text/javascript"}}],"id":"e7765b62-a244-4e75-8dbd-6d640bd00ad8","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/FHISTRY/2018/History","urlObject":{"path":["api","v2","performances-by-degrees-us","FHISTRY","2018","History"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"e7765b62-a244-4e75-8dbd-6d640bd00ad8"},{"name":"Delete one record","event":[{"listen":"test","script":{"id":"dbf75ad7-5daf-4c4c-8ce6-1d868fd387a1","exec":["pm.sendRequest({","    url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/\",","    method: 'POST',","    header: {","        'content-type': 'application/json'","    },","    body: {","        mode: 'raw',","        raw: JSON.stringify({ \"field-of-knowledge\": \"PruebaPOSTMAN\", \"year\": 5555, \"performance-percents\": \"0\", \"credits-passed\": 1870, \"credits-enrolled\": 2147, \"center\": \"FHISTRY\" })","    }","}, function (err, res) {","    pm.sendRequest({","        url: pm.variables.get(\"HOST\") + \"/api/v2/performances-by-degrees-us/FHISTRY/5555/PruebaPOSTMAN\",","        method: 'DELETE'","    }, function (err, res) {","        pm.test(\"Delete one record\", function(){","            pm.expect(res.code).equals(200);","        });","    });","});"],"type":"text/javascript"}}],"id":"0f2ed2fd-c7e9-4b71-99e8-15e19d520a08","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"DELETE","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/FHISTRY/2019/Prueba","urlObject":{"path":["api","v2","performances-by-degrees-us","FHISTRY","2019","Prueba"],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"0f2ed2fd-c7e9-4b71-99e8-15e19d520a08"},{"name":"Delete All Records","event":[{"listen":"test","script":{"id":"6858d418-a199-4be0-96fa-5b05943900b6","exec":["pm.test(\"Delete All Data\", function(){","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"046cd72a-c288-4edb-9fc2-38f05832c471","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"DELETE","header":[],"url":"http://127.0.0.1:3000/api/v2/performances-by-degrees-us/","urlObject":{"path":["api","v2","performances-by-degrees-us",""],"host":["http://127.0.0.1:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"046cd72a-c288-4edb-9fc2-38f05832c471"}],"event":[{"listen":"prerequest","script":{"id":"ed12a6bf-e413-49bf-8333-2e01780c9eec","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"3277702a-9f80-4a8b-a896-2ee49868d57f","type":"text/javascript","exec":[""]}}],"variable":[{"key":"HOST","value":"http://127.0.0.1:3000"}]}