code cleanup for pylint
All checks were successful
Pylint / build (3.12) (push) Successful in 9s
execute / build (3.12) (push) Successful in 25s

This commit is contained in:
Greg Gauthier 2024-07-22 19:26:27 +01:00
parent c6a87dff12
commit a727c58cf3
20 changed files with 467 additions and 466 deletions

View File

@ -1,6 +1,6 @@
name: execute
on: [push]
on: [ push ]
env:
BUILD_TYPE: Release
@ -10,34 +10,34 @@ jobs:
runs-on: ubuntu-gitea
strategy:
matrix:
python-version: ["3.12"]
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install -r requirements.txt
- name: Prep Env Files
run: |
touch .env.gw
touch .env.qa
- name: Run Open Api Tests
run: |
echo "API_URL=${{ vars.GAMMA_WORLD_API_URL }}" >> .env.gw
pytest -rA --durations=0 --color=auto --config-file=./pytest.ini -m rules
- name: Run Oauth2 Api Tests
run: |
echo "API_URL=${{ secrets.EDD_QA_API_URL }}" >> .env.qa
echo "CLIENT_ID=${{ secrets.EDD_CLIENT_ID }}" >> .env.qa
echo "CLIENT_SECRET=${{ secrets.EDD_CLIENT_SECRET }}" >> .env.qa
echo "TOKEN_FETCH_URL=${{ secrets.EDD_TOKEN_FETCH_URL }}" >> .env.qa
echo "LOGIN=${{ secrets.EDD_QA_LOGIN }}" >> .env.qa
echo "PASSWORD=${{ secrets.EDD_QA_PWD }}" >> .env.qa
echo "AUDIENCE=${{ secrets.EDD_AUDIENCE }}" >> .env.qa
echo "SCOPES=${{ secrets.EDD_SCOPES }}" >> .env.qa
pytest -rA --durations=0 --color=auto --config-file=./pytest.ini -m get
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install -r requirements.txt
- name: Prep Env Files
run: |
touch .env.gw
touch .env.qa
- name: Run Open Api Tests
run: |
echo "API_URL=${{ vars.GAMMA_WORLD_API_URL }}" >> .env.gw
pytest -rA --durations=0 --color=auto --config-file=./pytest.ini -m rules
- name: Run Oauth2 Api Tests
run: |
echo "API_URL=${{ secrets.EDD_QA_API_URL }}" >> .env.qa
echo "CLIENT_ID=${{ secrets.EDD_CLIENT_ID }}" >> .env.qa
echo "CLIENT_SECRET=${{ secrets.EDD_CLIENT_SECRET }}" >> .env.qa
echo "TOKEN_FETCH_URL=${{ secrets.EDD_TOKEN_FETCH_URL }}" >> .env.qa
echo "LOGIN=${{ secrets.EDD_QA_LOGIN }}" >> .env.qa
echo "PASSWORD=${{ secrets.EDD_QA_PWD }}" >> .env.qa
echo "AUDIENCE=${{ secrets.EDD_AUDIENCE }}" >> .env.qa
echo "SCOPES=${{ secrets.EDD_SCOPES }}" >> .env.qa
pytest -rA --durations=0 --color=auto --config-file=./pytest.ini -m get

View File

@ -1,24 +1,24 @@
name: Pylint
on: [push]
on: [ push ]
jobs:
build:
runs-on: ubuntu-gitea
strategy:
matrix:
python-version: ["3.12"]
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')

View File

@ -1,27 +1,35 @@
# pytest-api
This is a proof-of-concept project, showing how PyTest could be used in combination with a custom API client, to quickly and easily build api tests for a data-delivery service that is deployed and active on an existing environment.
This is a proof-of-concept project, showing how PyTest could be used in combination with a custom API client, to quickly
and easily build api tests for a data-delivery service that is deployed and active on an existing environment.
## Instructions
1. Add a `.env` file to your local copy of the repo. By default, this demo project will look for `.env.qa` in the root of the project. You can find a template to base this on, in `apiclient/env_template`. Info on how to set the values in that file can be found by asking Greg.
1. Add a `.env` file to your local copy of the repo. By default, this demo project will look for `.env.qa` in the root
of the project. You can find a template to base this on, in `apiclient/env_template`. Info on how to set the values
in that file can be found by asking Greg.
2. Create your virtual env:
```shell
python3 -m venv venv
```
3. Activate the environment:
```shell
source venv/bin/activate
```
On Windows:
```shell
.\venv\Scripts\activate
```
4. Install requirements (pip will come from your venv)
```shell
pip install -r requirements.txt
```
@ -70,7 +78,8 @@ PASSED tests/test_datadelivery.py::test_datadelivery_redaction_type_get
================================================================================================== 5 passed, 5 warnings in 17.20s ===================================================================================================
```
PyTest is configured to show the top 25 test durations, as well as the pass/fail status of all the tests. The tests have been marked with various tags, to allow for granular test selection. To see all the available markers:
PyTest is configured to show the top 25 test durations, as well as the pass/fail status of all the tests. The tests have
been marked with various tags, to allow for granular test selection. To see all the available markers:
```
(.venv) PS C:\Users\GregGauthier\Projects\local\pytest-api> pytest --markers

View File

@ -6,7 +6,6 @@ from requests_oauthlib import OAuth2Session
def api_client(call_dict, verify_cert=False, oauth=False):
method = call_dict["method"]
url = call_dict["url"]
headers = call_dict["headers"]
@ -35,10 +34,9 @@ def api_client(call_dict, verify_cert=False, oauth=False):
except RequestException as e:
print(f"Request failed. Method: {method}, URL: {url}", file=sys.stderr)
print(f"Error details: {str(e)}", file=sys.stderr)
exit(e.response.status_code)
sys.exit(e.response.status_code)
if response.status_code == 200:
return response.json()
else:
return response.status_code, response.reason
return response.status_code, response.reason

View File

@ -1,7 +1,7 @@
import os
from dotenv import dotenv_values
from types import MappingProxyType
from dotenv import dotenv_values
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View File

@ -1,8 +1,8 @@
import json
from apiclient.config import get_cfg
from apiclient.client import api_client
from apiclient.oauth_helper import get_legacy_token
from apiclient.client import api_client
from apiclient.config import get_cfg
from apiclient.oauth_helper import get_legacy_token
ENV = 'qa'
cfg = get_cfg(ENV)

View File

@ -1,7 +1,9 @@
import sys
from oauthlib.oauth2 import LegacyApplicationClient, OAuth2Error
from requests_oauthlib import OAuth2Session
from apiclient.config import get_cfg
import sys
def get_legacy_token(env):
@ -22,6 +24,6 @@ def get_legacy_token(env):
)
except OAuth2Error as e:
print("OAuth2 Error: ", str(e), file=sys.stderr)
exit(e.status_code)
sys.exit(e.status_code)
return token

View File

@ -3,3 +3,4 @@ requests~=2.32.3
requests-oauthlib~=2.0.0
python-dotenv~=1.0.1
pytest~=8.2.2
pylint~=3.2.6

View File

@ -17,4 +17,3 @@ def reset_oauth_session():
oauth_session.cookies.clear()
yield oauth_session
oauth_session.close()

View File

@ -1,15 +1,13 @@
import os
import json
import os
CWD = os.path.dirname(os.path.realpath(__file__))
####
# HELPERS
####
def get_expected_response(test_name):
def get_expected_response(pkg, test_name):
expected_response_file = test_name + ".json"
with open(os.path.join(CWD, 'expected_responses', expected_response_file), 'r') as file:
with open(
os.path.join(CWD, pkg, 'expected_responses', expected_response_file),
'r', encoding="utf8") as file:
expected_response = json.load(file)
return expected_response

View File

@ -1,8 +1,9 @@
# pylint: disable=line-too-long,unused-argument
import pytest
from apiclient.config import get_cfg
from apiclient.oauth_helper import get_legacy_token
ENV = 'qa'
CFG = get_cfg(ENV, force_refresh=True)
application_json = {'Content-Type': 'application/json'}

View File

@ -1,42 +1,42 @@
[
{
"ClientId" : "e72cdfde-957a-4f65-9f5e-c7b18e95d8dc",
"ClientSecret" : "f4ca195c-989c-48e6-a002-b1fb7b3c03fd",
"IsActive" : 1,
"Name" : "testcase",
"date_of_generation" : "2024-04-25 04:48:47",
"id" : 1,
"last_connection" : null,
"organization_id" : 16
},
{
"ClientId" : "b0dd74c2-9f39-45fc-a52e-b1130ffddbb5",
"ClientSecret" : "71b2ab0e-d3fa-40e2-a40e-2088ae716a46",
"IsActive" : 1,
"Name" : "Test",
"date_of_generation" : "2024-05-20 07:22:31",
"id" : 2,
"last_connection" : null,
"organization_id" : 1
},
{
"ClientId" : "be1a0686-fed2-4d79-a04c-c473c6c3e22e",
"ClientSecret" : "ddfdaee7-1fe5-4f62-964c-cb2b8e8397e1",
"IsActive" : 1,
"Name" : "Test3",
"date_of_generation" : "2024-05-20 10:58:35",
"id" : 3,
"last_connection" : null,
"organization_id" : 1
},
{
"ClientId" : "37f7afc6-91a1-4c2d-9696-0e8db6fc1bc6",
"ClientSecret" : "40106ff7-7feb-4869-b4c9-eeed5dee2f36",
"IsActive" : 1,
"Name" : "test4",
"date_of_generation" : "2024-05-20 11:14:16",
"id" : 4,
"last_connection" : null,
"organization_id" : 1
}
{
"ClientId": "e72cdfde-957a-4f65-9f5e-c7b18e95d8dc",
"ClientSecret": "f4ca195c-989c-48e6-a002-b1fb7b3c03fd",
"IsActive": 1,
"Name": "testcase",
"date_of_generation": "2024-04-25 04:48:47",
"id": 1,
"last_connection": null,
"organization_id": 16
},
{
"ClientId": "b0dd74c2-9f39-45fc-a52e-b1130ffddbb5",
"ClientSecret": "71b2ab0e-d3fa-40e2-a40e-2088ae716a46",
"IsActive": 1,
"Name": "Test",
"date_of_generation": "2024-05-20 07:22:31",
"id": 2,
"last_connection": null,
"organization_id": 1
},
{
"ClientId": "be1a0686-fed2-4d79-a04c-c473c6c3e22e",
"ClientSecret": "ddfdaee7-1fe5-4f62-964c-cb2b8e8397e1",
"IsActive": 1,
"Name": "Test3",
"date_of_generation": "2024-05-20 10:58:35",
"id": 3,
"last_connection": null,
"organization_id": 1
},
{
"ClientId": "37f7afc6-91a1-4c2d-9696-0e8db6fc1bc6",
"ClientSecret": "40106ff7-7feb-4869-b4c9-eeed5dee2f36",
"IsActive": 1,
"Name": "test4",
"date_of_generation": "2024-05-20 11:14:16",
"id": 4,
"last_connection": null,
"organization_id": 1
}
]

View File

@ -1,22 +1,22 @@
[
{
"description" : "RAW A717 Redaction Type",
"name" : "RAWA717",
"redactiontype_id" : 1
},
{
"description" : "RAW A767 Redaction Type",
"name" : "RAWA767",
"redactiontype_id" : 2
},
{
"description" : "CSV Redaction Type",
"name" : "CSV",
"redactiontype_id" : 3
},
{
"description" : "PARQUET Redaction Type",
"name" : "PARQUET",
"redactiontype_id" : 4
}
{
"description": "RAW A717 Redaction Type",
"name": "RAWA717",
"redactiontype_id": 1
},
{
"description": "RAW A767 Redaction Type",
"name": "RAWA767",
"redactiontype_id": 2
},
{
"description": "CSV Redaction Type",
"name": "CSV",
"redactiontype_id": 3
},
{
"description": "PARQUET Redaction Type",
"name": "PARQUET",
"redactiontype_id": 4
}
]

View File

@ -1,184 +1,184 @@
[
{
"application_id": 1,
"role_admin": 0,
"role_id": 151,
"role_name": "Administrator",
"role_standard": 1
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5362,
"role_name": "API_Non_Admin_ViewOnly_Enginetypes",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6459,
"role_name": "API_TEST_MLBCUJ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6363,
"role_name": "API_TEST_MPOYIM",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6354,
"role_name": "API_TEST_STOZBG",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5844,
"role_name": "clone_admin_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6200,
"role_name": "create_aircraft_groups_nonadmin_api",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6223,
"role_name": "create_aircraft_groups_nonadmin_api01",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6043,
"role_name": "create_not_allowed",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6056,
"role_name": "create_not_allowed_1",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6059,
"role_name": "create_not_allowed_22",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5978,
"role_name": "delete_non_admin_airframer",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5372,
"role_name": "manage_config_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5537,
"role_name": "new_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5733,
"role_name": "new_role_sample",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5839,
"role_name": "Sample_data",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5548,
"role_name": "smample_role_009",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5546,
"role_name": "t_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 1,
"role_id": 152,
"role_name": "TDY Administrator",
"role_standard": 1
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5628,
"role_name": "Test_4",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5538,
"role_name": "Test_Sample_21",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4602,
"role_name": "test_sample_3 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4609,
"role_name": "test_sample_4 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5736,
"role_name": "Test_Sample_data",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4595,
"role_name": "test_sample3 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6257,
"role_name": "view_aircraftmodel_nonadmin1",
"role_standard": 0
}
{
"application_id": 1,
"role_admin": 0,
"role_id": 151,
"role_name": "Administrator",
"role_standard": 1
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5362,
"role_name": "API_Non_Admin_ViewOnly_Enginetypes",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6459,
"role_name": "API_TEST_MLBCUJ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6363,
"role_name": "API_TEST_MPOYIM",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6354,
"role_name": "API_TEST_STOZBG",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5844,
"role_name": "clone_admin_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6200,
"role_name": "create_aircraft_groups_nonadmin_api",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6223,
"role_name": "create_aircraft_groups_nonadmin_api01",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6043,
"role_name": "create_not_allowed",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6056,
"role_name": "create_not_allowed_1",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6059,
"role_name": "create_not_allowed_22",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5978,
"role_name": "delete_non_admin_airframer",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5372,
"role_name": "manage_config_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5537,
"role_name": "new_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5733,
"role_name": "new_role_sample",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5839,
"role_name": "Sample_data",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5548,
"role_name": "smample_role_009",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5546,
"role_name": "t_role",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 1,
"role_id": 152,
"role_name": "TDY Administrator",
"role_standard": 1
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5628,
"role_name": "Test_4",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5538,
"role_name": "Test_Sample_21",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4602,
"role_name": "test_sample_3 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4609,
"role_name": "test_sample_4 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 5736,
"role_name": "Test_Sample_data",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 4595,
"role_name": "test_sample3 ",
"role_standard": 0
},
{
"application_id": 1,
"role_admin": 0,
"role_id": 6257,
"role_name": "view_aircraftmodel_nonadmin1",
"role_standard": 0
}
]

View File

@ -1,8 +1,12 @@
import json
import pytest
from apiclient.client import api_client
from tests.oauth_service.helpers import get_expected_response
import pytest
from apiclient.client import api_client
from tests.helpers import get_expected_response
pkg_name = __package__.split('.')[1]
####
# NOTE:
@ -13,7 +17,7 @@ from tests.oauth_service.helpers import get_expected_response
@pytest.mark.get
@pytest.mark.role
def test_datadelivery_role_get(request, role_get_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(role_get_call, oauth=True)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)
@ -21,7 +25,7 @@ def test_datadelivery_role_get(request, role_get_call):
@pytest.mark.get
@pytest.mark.redaction
def test_datadelivery_acms_redaction_get(request, acms_redaction_get_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name,request.node.name)
actual_response = api_client(acms_redaction_get_call, oauth=True)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)
@ -29,7 +33,7 @@ def test_datadelivery_acms_redaction_get(request, acms_redaction_get_call):
@pytest.mark.get
@pytest.mark.client_application
def test_datadelivery_client_applications_get(request, client_applications_get_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(client_applications_get_call, oauth=True)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)
@ -37,7 +41,7 @@ def test_datadelivery_client_applications_get(request, client_applications_get_c
@pytest.mark.get
@pytest.mark.endpoint
def test_datadelivery_endpoint_get(request, endpoint_get_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(endpoint_get_call, oauth=True)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)
@ -45,6 +49,6 @@ def test_datadelivery_endpoint_get(request, endpoint_get_call):
@pytest.mark.get
@pytest.mark.redaction
def test_datadelivery_redaction_type_get(request, redaction_type_get_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(redaction_type_get_call, oauth=True)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)

View File

@ -1,6 +1,7 @@
# pylint: disable=line-too-long,unused-argument
import pytest
from apiclient.config import get_cfg
from apiclient.config import get_cfg
CFG = get_cfg('gw', force_refresh=True)

View File

@ -1,67 +1,67 @@
{
"number": [
3,
6,
0
],
"morale": [
2,
4,
0
],
"hit dice": [
6,
6,
0
],
"armour": 5,
"environ": [
"land"
],
"land speed": [
12,
900,
18
],
"ms": [
1,
10,
8
],
"in": [
3,
6,
0
],
"dx": [
1,
10,
11
],
"ch": [
1,
10,
2
],
"cn": [
1,
6,
8
],
"ps": [
1,
10,
5
],
"attacks": {
"bite": [
1,
6,
0
]
},
"mutations": [
"Empathy"
],
"description": "1.5 meter tall bipedal mutated badgers. They inhabit temperate areas. Organized into Tech Level II societies run by their 'nobility'. 10% chance of each badder in a party having 1 Tech Level III weapon. 10d10 males of fighting age live in tunnels under their villages."
"number": [
3,
6,
0
],
"morale": [
2,
4,
0
],
"hit dice": [
6,
6,
0
],
"armour": 5,
"environ": [
"land"
],
"land speed": [
12,
900,
18
],
"ms": [
1,
10,
8
],
"in": [
3,
6,
0
],
"dx": [
1,
10,
11
],
"ch": [
1,
10,
2
],
"cn": [
1,
6,
8
],
"ps": [
1,
10,
5
],
"attacks": {
"bite": [
1,
6,
0
]
},
"mutations": [
"Empathy"
],
"description": "1.5 meter tall bipedal mutated badgers. They inhabit temperate areas. Organized into Tech Level II societies run by their 'nobility'. 10% chance of each badder in a party having 1 Tech Level III weapon. 10d10 males of fighting age live in tunnels under their villages."
}

View File

@ -1,62 +1,62 @@
[
"android",
"ark",
"arn",
"badder",
"barl nep",
"ber lep",
"bigoon",
"blaash",
"blackun",
"blight",
"blood bird",
"brutorz",
"buggem",
"cal then",
"carrin",
"centisteed",
"cren tosh",
"crep plant",
"dabber",
"ert",
"ert telden",
"fen",
"fleshin",
"gator",
"gren",
"hawkoid",
"herkel",
"herp",
"hisser",
"hoop",
"hopper",
"horl choo",
"jaget",
"kai lin",
"kamodo",
"keeshin",
"kep plant",
"lil",
"manta",
"menarl",
"narl ep",
"obb",
"orlen",
"parn",
"perth",
"pineto",
"podog",
"rakox",
"sep",
"serf",
"seroon lou",
"sleeth",
"soul besh",
"squeeker",
"terl",
"wardent",
"win seen",
"yexil",
"zarn",
"zeethh"
"android",
"ark",
"arn",
"badder",
"barl nep",
"ber lep",
"bigoon",
"blaash",
"blackun",
"blight",
"blood bird",
"brutorz",
"buggem",
"cal then",
"carrin",
"centisteed",
"cren tosh",
"crep plant",
"dabber",
"ert",
"ert telden",
"fen",
"fleshin",
"gator",
"gren",
"hawkoid",
"herkel",
"herp",
"hisser",
"hoop",
"hopper",
"horl choo",
"jaget",
"kai lin",
"kamodo",
"keeshin",
"kep plant",
"lil",
"manta",
"menarl",
"narl ep",
"obb",
"orlen",
"parn",
"perth",
"pineto",
"podog",
"rakox",
"sep",
"serf",
"seroon lou",
"sleeth",
"soul besh",
"squeeker",
"terl",
"wardent",
"win seen",
"yexil",
"zarn",
"zeethh"
]

View File

@ -1,15 +0,0 @@
import os
import json
CWD = os.path.dirname(os.path.realpath(__file__))
####
# HELPERS
####
def get_expected_response(test_name):
expected_response_file = test_name + ".json"
with open(os.path.join(CWD, 'expected_responses', expected_response_file), 'r') as file:
expected_response = json.load(file)
return expected_response

View File

@ -1,19 +1,22 @@
import json
import pytest
from apiclient.client import api_client
from tests.open_service.helpers import get_expected_response
from tests.helpers import get_expected_response
pkg_name = __package__.split('.')[1]
@pytest.mark.rules
def test_get_creatures(request, get_creatures_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(get_creatures_call, oauth=False)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)
@pytest.mark.rules
def test_get_creature(request, get_creature_call):
expected_response = get_expected_response(request.node.name)
expected_response = get_expected_response(pkg_name, request.node.name)
actual_response = api_client(get_creature_call, oauth=False)
assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)