You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebServices/src/Tests/postman/Catalog_Exercices.postman_c...

232 lines
5.9 KiB

{
"info": {
"_postman_id": "c019ebd5-bed6-49ea-a584-086e91bfe503",
"name": "Catalog Exercices",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Créer un exercice",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.test('Status code is 201', function() {",
" pm.response.to.have.status(201);",
"});",
"pm.test('L\'exercice a un id', function() {",
" pm.expect(jsonData.id).to.be.a('string');",
"});",
"pm.environment.set('exerciceId', jsonData.id);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Pompes\",\n \"description\": \"Exercice de musculation pour les pectoraux\",\n \"target\": 1,\n \"imageUrl\": \"images/pompes.jpg\",\n \"videoUrl\": \"https://www.youtube.com/watch?v=IODxDxX7oi4\"\n}"
},
"url": {
"raw": "{{catalogApi}}/api/exercices",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices"
]
}
}
},
{
"name": "Récupérer l'exercice par id",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.test('Status code is 200', function() {",
" pm.response.to.have.status(200);",
"});",
"pm.test('Nom de l\\'exercice est Pompes', function() {",
" pm.expect(jsonData.name).to.eq('Pompes');",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{catalogApi}}/api/exercices/{{exerciceId}}",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices",
"{{exerciceId}}"
]
}
}
},
{
"name": "Mettre à jour l'exercice",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 204', function() {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"{{exerciceId}}\",\n \"name\": \"Pompes modifiées\",\n \"description\": \"Exercice modifié\",\n \"target\": 2,\n \"imageUrl\": \"images/pompes_mod.jpg\",\n \"videoUrl\": \"https://www.youtube.com/watch?v=abcd\"\n}"
},
"url": {
"raw": "{{catalogApi}}/api/exercices/{{exerciceId}}",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices",
"{{exerciceId}}"
]
}
}
},
{
"name": "Vérifier la mise à jour",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.test('Status code is 200', function() {",
" pm.response.to.have.status(200);",
"});",
"pm.test('Nom de l\\'exercice est Pompes modifiées', function() {",
" pm.expect(jsonData.name).to.eq('Pompes modifiées');",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{catalogApi}}/api/exercices/{{exerciceId}}",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices",
"{{exerciceId}}"
]
}
}
},
{
"name": "Supprimer l'exercice",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 204', function() {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "DELETE",
"header": [],
"url": {
"raw": "{{catalogApi}}/api/exercices/{{exerciceId}}",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices",
"{{exerciceId}}"
]
}
}
},
{
"name": "Vérifier la suppression",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 404', function() {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{catalogApi}}/api/exercices/{{exerciceId}}",
"host": [
"{{catalogApi}}"
],
"path": [
"api",
"exercices",
"{{exerciceId}}"
]
}
}
}
],
"variable": [
{
"key": "catalogApi",
"value": "http://localhost:5000"
}
]
}