{"id":19335992,"url":"https://github.com/taurus5650/automation_api_test_pytest","last_synced_at":"2025-02-24T07:43:42.045Z","repository":{"id":231690518,"uuid":"782438677","full_name":"taurus5650/automation_api_test_pytest","owner":"taurus5650","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-01T12:46:05.000Z","size":2264,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-06T09:46:00.005Z","etag":null,"topics":["api-testing","automation-testing","pytest","python","python3","software-testing","testing-automation","testing-framework","testing-practices"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taurus5650.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-05T09:54:33.000Z","updated_at":"2024-09-01T12:46:08.000Z","dependencies_parsed_at":"2024-04-05T11:29:50.303Z","dependency_job_id":"861b2dc3-a5d3-42b8-b9fe-d979f76181de","html_url":"https://github.com/taurus5650/automation_api_test_pytest","commit_stats":null,"previous_names":["taurus5650/automation_api_test_pytest"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taurus5650%2Fautomation_api_test_pytest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taurus5650%2Fautomation_api_test_pytest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taurus5650%2Fautomation_api_test_pytest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taurus5650%2Fautomation_api_test_pytest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taurus5650","download_url":"https://codeload.github.com/taurus5650/automation_api_test_pytest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240441868,"owners_count":19801791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-testing","automation-testing","pytest","python","python3","software-testing","testing-automation","testing-framework","testing-practices"],"created_at":"2024-11-10T03:09:32.712Z","updated_at":"2025-02-24T07:43:41.924Z","avatar_url":"https://github.com/taurus5650.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testing Restful API with Python Pytest\n\n## Purpose\n- For testing, which using \n  - Pytest framework \n  - Jenkins \n  - Allure report \n  - Docker \n- Support testing \n  - Restful api testing (Testing resouces : https://fakerestapi.azurewebsites.net)\n\n## Directory Structure\n```\ngit ls-tree -r --name-only HEAD | tree --fromfile\n.\n├── .gitignore\n├── README.md\n├── business\n│   ├── api_request.py\n│   ├── books\n│   │   ├── books_api.py\n│   │   └── books_database.py\n│   ├── database_execution.py\n│   └── users\n│       ├── users_api.py\n│       └── users_database.py\n├── configurations\n│   ├── __init__.py\n│   ├── api_domain.py\n│   └── database.py\n├── conftest.py\n├── deployments\n│   ├── Dockerfile\n│   ├── Jenkinsfile\n│   └── job_configurations.json\n├── logger.py\n├── requirements.txt\n└── test_suites\n    ├── test_books\n    │   └── test_get_books_id.py\n    └── test_users\n        ├── test_get_users.py\n        └── test_post_users.py\n\n```\n\n## Step-by-step\n### Option 1: Build up a simple Docker\nInput the command\n```\ndocker build -t pytest_learn_image -f ./deployments/Dockerfile .\n```\n### Option 2: Build up Jenkins Docker\n_Ref: [How to Run Jenkins Container as Systemd Service with Docker](https://discuss.circleci.com/t/how-can-i-extract-the-junit-xml-files-from-within-a-docker-container-in-docker/24089/2)_\n1. Build a Jenkins run in Docker\n- `--name jenkins` : Container naming\n- `-p 8080:8080` : Container 8080 port mapping to localhost 8080 port, which for jenkins administrator login.\n- `-p 50000:50000` Container 50000 port mapping to localhost 50000 port, which for jenkins slave node's JNLP (Java Web Start) port.\n- `-v ~/jenkins_home:/var/jenkins_home` : Build up docker volume. Container /var/jenkins_home mapping to localhost ~/jenkins_home.\n- `-v /var/run/docker.sock:/var/run/docker.sock` : Let containers can use docker daemon.\n```\n$ docker run --name jenkins -p 8080:8080 -p 50000:50000 -v ~/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins:lts\n```\n\n2. Started the container and command for installation\n```\n$ apt-get update\n$ apt install python3\n$ apt install python3.11-venv\n$ apt-get install -y wget\n$ wget https://github.com/allure-framework/allure2/releases/download/2.14.0/allure-2.14.0.zip\n$ unzip allure-2.14.0.zip\n$ export PATH=$PATH:/path/to/allure-2.14.0/bin\n```\n_Note: If docker cli encountering no permission_\n```\n$ docker exec -u 0 -it {#CONTAINER_ID} /bin/bash\n```\n\n3. Launch browser way to http://localhost:8080/ \\\na. Unlock the Jenkins with password. The password form container's logs when u started the container.\\\nb. Install suggested plugins.\n_Ref. [How to Run Jenkins Container as Systemd Service with Docker](https://www.linuxtechi.com/run-jenkins-docker-container-systemd/)_\n\n4. Change Jenkinsfile configurations \\\na. `GIT_REPO` : Ur repo \\\nb. `_GIT_CREDENTIALS_ID` : From Jenkins credentials setting Ref How To Add Git Credentials In Jenkins \\\n_Ref. [Configuring the Git Credentials in Jenkins](https://medium.com/@nikhil.nagarajappa/configuring-the-git-credentials-in-jenkins-4b584a797b45)_\n![Jenkinsfile_config.png](readme%2FJenkinsfile_config.png)\n\n5. Change job configurations\nIn this case, the pipeline job will separate by services. \\\nThus, We may create the pipeline by services. \\\nBefore create the Jenkins pipeline, we need to add job in `job_configuration.json`. \\ \n```\n└── test_suites\n    ├── test_books\n    │   └── test_get_books_id.py\n    └── test_users\n        ├── test_get_users.py\n        └── test_post_users.py\n```\n![job_config_json.png](readme%2Fjob_config_json.png)\n\n6. Build Jenkins pipeline, select [new items] build a new job.\n![jenkins_new_item.png](readme%2Fjenkins_new_item.png)\n\n7. Give a job naming and select pipeline\n![jenkins_choose_pipeline.png](readme%2Fjenkins_choose_pipeline.png)\n\n8. Do the config\n- `Repository URL` : # Git repo\n- `Credentials` : _Ref. [Configuring the Git Credentials in Jenkins](https://medium.com/@nikhil.nagarajappa/configuring-the-git-credentials-in-jenkins-4b584a797b45)_\n- `Branches to build` : */master\n- `Script Path` : deployments/Jenkinsfile\n![jenkins_pipeline_config.png](readme%2Fjenkins_pipeline_config.png)\n\n9. Okieee, then run the job. Click [Build parameters]\n![jenkins_job_builds_params.png](readme%2Fjenkins_job_builds_params.png)\n\n10. Input parameters (optional, if didn't input then run as default)\n![job_run_build.png](readme%2Fjob_run_build.png)\n\n11. Job complete\n![jenkins_job_complete.png](readme%2Fjenkins_job_complete.png)\n\n12. May way to allure report to check the result :)\n![allure_report.png](readme%2Fallure_report.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaurus5650%2Fautomation_api_test_pytest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaurus5650%2Fautomation_api_test_pytest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaurus5650%2Fautomation_api_test_pytest/lists"}