diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..9d74bee4a --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,41 @@ +# Python package +# Create and test a Python package on multiple Python versions. +# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' +strategy: + matrix: + Python37: + python.version: '3.7' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip + pip install -r requirements.txt + displayName: 'Install dependencies' + +- script: | + pip install pytest pytest-azurepipelines + pytest + displayName: 'pytest' + +- task: CmdLine@2 + displayName: 'install newman' + inputs: + script: 'sudo npm install -g newman' + workingDirectory: $(System.DefaultWorkingDirectory) +- task: CmdLine@2 + displayName: 'Run tests' + inputs: + script: 'newman run starterapi.json' + workingDirectory: $(Build.SourcesDirectory) diff --git a/starterapi.json b/starterapi.json new file mode 100644 index 000000000..57e5ca3dc --- /dev/null +++ b/starterapi.json @@ -0,0 +1,94 @@ +{ + "info": { + "_postman_id": "968b3a18-cc72-48a2-9b6b-e8619b4aaca8", + "name": "Starter APIs", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Create Employee", + "event": [ + { + "listen": "test", + "script": { + "id": "38b1717c-45ae-477f-8dae-8e889ba381d5", + "exec": [ + "pm.test(\"Successful response\", function () {", + " pm.expect(pm.response.text()).to.include(\"success\");", + "});", + "var json = pm.response.json();", + "pm.environment.set(\"id\", json.data.id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"{{name}}\",\n \"salary\": \"{{salary}}\",\n \"age\": \"{{age}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "http://dummy.restapiexample.com/api/v1/create", + "protocol": "http", + "host": [ + "dummy", + "restapiexample", + "com" + ], + "path": [ + "api", + "v1", + "create" + ] + } + }, + "response": [] + }, + { + "name": "Get All Employees", + "event": [ + { + "listen": "test", + "script": { + "id": "af3cb111-e3ac-4174-b8ca-7f4127a0285d", + "exec": [ + "pm.test(\"Successful response\", function () {", + " pm.expect(pm.response.text()).to.include(\"success\");", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://dummy.restapiexample.com/api/v1/employees", + "protocol": "http", + "host": [ + "dummy", + "restapiexample", + "com" + ], + "path": [ + "api", + "v1", + "employees" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} +}