Skip to content

Commit

Permalink
Merge pull request #307 from dimagi/kt/update_api_readme
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
kiran-tripathy authored Feb 28, 2024
2 parents acf0233 + dd7114e commit 0e8de5f
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions RequestAPI/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Automated API Python Requests
# Automated API Requests
Automated test suite for [CommCare HQ APIs](https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143958022/CommCare+HQ+APIs)

## Setting up test environment
## Executing Scripts

### <ins> On Local Machine </ins>

#### Setting up test environment

```sh

# create and activate a virtualenv using your preferred method. Example:
python -m venv venv
source venv/bin/activate


# install requirements
pip install -r requirements.txt

```

## Running Tests
[More on setting up virtual environments](https://confluence.dimagi.com/display/GTD/QA+and+Python+Virtual+Environments)

#### Running Tests

- Copy `settings-sample.cfg` to `settings.cfg` and populate `settings.cfg` for
the environment you want to test.


- Run tests

```sh
Expand All @@ -33,7 +40,25 @@ pytest -v -k test_01/test_case_1

```
- Similarly, you could pass the following arguments:
- `-n auto --dist=loadfile` - This will run the tests parallelly; it'll automatically choose the number of instances . The number of reruns is configurable.
- `--reruns 1` - This will re-run the tests once in case of failures.The number of reruns is configurable too.
- `--capture=tee-sys` - This disables all capturing and replaces sys.stdout/stderr with in-mem files
- `--tb=short` - This enables shorter traceback format
- `-n auto --dist=loadfile` - This will run the tests parallelly; it'll automatically choose the number of instances. The number of reruns is configurable.
- `--reruns 1` - This will re-run the tests once in case of failures. The number of reruns is configurable too.
- `--capture=tee-sys` - This disables all capturing and replaces sys. stdout/stderr with in-mem files
- `--tb=short` - This enables a shorter traceback format

### <ins> Trigger Manually on Gitaction </ins>

<img align="right" width="400" src="https://github.com/dimagi/dimagi-qa/assets/67914792/002fbfd3-2512-4e12-a8ea-e57f93f5a615" alt="clone this repository" />

To manually trigger the script,
- Go to [Gitactions](https://github.com/dimagi/dimagi-qa/actions/)
- Select the desired workflow, here [Python Request API action](https://github.com/dimagi/dimagi-qa/actions/workflows/request_api.yml)
- Run workflow
- Select workflow as ```master```
- Select the environment as desired
- Run!

If you are a part of the QA team, you'll receive emails for the result of the run after it's complete.

<img align="right" width="400" src="https://user-images.githubusercontent.com/67914792/168756705-88e4b330-b05a-4df2-a60c-7d45e8a2d002.PNG" alt="clone this repository" />

Besides, you should be able to find the zipped results in the **Artifacts** section, of the corresponding run (after it's complete).

0 comments on commit 0e8de5f

Please sign in to comment.