Skip to content

Commit

Permalink
Reports Tests for Public-API (#18)
Browse files Browse the repository at this point in the history
* created hypothesis mock for data view

* mock data with dynamic equipment

* working but for some reason invalid data if empty equipment

* ignore vscode settings

* adding logger warnnings to everything

* ouption int and validator to allow none or int

* dictioanry refined for report, status should be 201

* Update test_report_api.py

* remove debug logs

* revert to original

* equipment dictionary if none should be 0

* loud test to get output when debugging

* default should be 0 if not given

* revert to original

* my linux doing ??

* None > 0

* add settings

---------

Co-authored-by: extreme4all <>
  • Loading branch information
RusticPotatoes authored Nov 6, 2023
1 parent c169c4c commit f305f7b
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 170 deletions.
150 changes: 75 additions & 75 deletions .github/workflows/pytest-workflow-manual.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
name: Pytest report manual

on:
workflow_dispatch:

permissions:
contents: read

jobs:
Linter-Unknown-Owner:
name: Black Syntax Check on Public
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install python3-venv package
run: sudo apt update && sudo apt install python3-venv -y

- name: Run Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./src"

Build-Test-Unknown-Owner:
name: Setup and Run Tests on Public
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11.6"

- name: Setup Docker Containers
run: |
make setup-detached
- name: Check API is Up
uses: cygnetdigital/[email protected]
with:
url: 'http://localhost:5000/docs'
responseCode: '200,500'
timeout: 120000 # wait up to 120 seconds
interval: 5000 # poll every 5 seconds

- name: Generate Pytest Report
run: |
make test-report
# https://github.com/marketplace/actions/pytest-results-actions
- name: Surface Failing Tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: pytest_report.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
name: Pytest report manual

on:
workflow_dispatch:

permissions:
contents: read

jobs:
Linter-Unknown-Owner:
name: Black Syntax Check on Public
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install python3-venv package
run: sudo apt update && sudo apt install python3-venv -y

- name: Run Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./src"

Build-Test-Unknown-Owner:
name: Setup and Run Tests on Public
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11.6"

- name: Setup Docker Containers
run: |
make setup-detached
- name: Check API is Up
uses: cygnetdigital/[email protected]
with:
url: 'http://localhost:5000/docs'
responseCode: '200,500'
timeout: 120000 # wait up to 120 seconds
interval: 5000 # poll every 5 seconds

- name: Generate Pytest Report
run: |
make test-report
# https://github.com/marketplace/actions/pytest-results-actions
- name: Surface Failing Tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: pytest_report.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
168 changes: 84 additions & 84 deletions .github/workflows/pytest-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
name: Pytest report

on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop

permissions:
contents: read

jobs:
linter:
name: Black Syntax Check
runs-on: [self-hosted, "hetzner"]
if: github.repository_owner == 'Bot-detector'
steps:
- uses: actions/checkout@v3

- name: Install python3-venv package
run: sudo apt update && sudo apt install python3-venv -y

- name: Run Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./src"

Build-Test:
name: Setup Enviornment and Run Tests
runs-on: [self-hosted, "hetzner"]
if: github.repository_owner == 'Bot-detector'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11.6"

- name: Setup Docker Containers
run: |
make setup-detached
- name: Check API is Up
uses: cygnetdigital/[email protected]
with:
url: "http://localhost:5000/docs"
responseCode: "200,500"
timeout: 120000 # wait up to 120 seconds
interval: 5000 # poll every 5 seconds

- name: Generate Pytest Report
run: |
make test-report
# https://github.com/marketplace/actions/pytest-results-actions
- name: Surface Failing Tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: pytest_report.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
name: Pytest report

on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop

permissions:
contents: read

jobs:
linter:
name: Black Syntax Check
runs-on: [self-hosted, "hetzner"]
if: github.repository_owner == 'Bot-detector'
steps:
- uses: actions/checkout@v3

- name: Install python3-venv package
run: sudo apt update && sudo apt install python3-venv -y

- name: Run Black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./src"

Build-Test:
name: Setup Enviornment and Run Tests
runs-on: [self-hosted, "hetzner"]
if: github.repository_owner == 'Bot-detector'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11.6"

- name: Setup Docker Containers
run: |
make setup-detached
- name: Check API is Up
uses: cygnetdigital/[email protected]
with:
url: "http://localhost:5000/docs"
responseCode: "200,500"
timeout: 120000 # wait up to 120 seconds
interval: 5000 # poll every 5 seconds

- name: Generate Pytest Report
run: |
make test-report
# https://github.com/marketplace/actions/pytest-results-actions
- name: Surface Failing Tests
if: always()
uses: pmeier/pytest-results-action@main
with:
# A list of JUnit XML files, directories containing the former, and wildcard
# patterns to process.
# See @actions/glob for supported patterns.
path: pytest_report.xml

# Add a summary of the results at the top of the report
# Default: true
summary: true

# Select which results should be included in the report.
# Follows the same syntax as
# `pytest -r`
# Default: fEX
display-options: fEX

# Fail the workflow if no JUnit XML was found.
# Default: true
fail-on-empty: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# .vscode/*
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"python.testing.pytestArgs": [
"src"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"isort.args":["--profile", "black"],
}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ venv-create: venv-remove ## cleans the .venv then creates a venv in the folder .
python3 -m venv .venv

venv-remove: ## removes the .venv folder
rm -rf .venv
rm -rf .venv

test-loud: ## runs pytest with verbose output
python3 -m pytest --verbose -s
22 changes: 12 additions & 10 deletions src/app/views/input/report.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from pydantic import BaseModel
from typing import Optional

from pydantic import BaseModel, validator
from pydantic.fields import Field


class Equipment(BaseModel):
equip_head_id: int = Field(None, ge=0)
equip_amulet_id: int = Field(None, ge=0)
equip_torso_id: int = Field(None, ge=0)
equip_legs_id: int = Field(None, ge=0)
equip_boots_id: int = Field(None, ge=0)
equip_cape_id: int = Field(None, ge=0)
equip_hands_id: int = Field(None, ge=0)
equip_weapon_id: int = Field(None, ge=0)
equip_shield_id: int = Field(None, ge=0)
equip_head_id: Optional[int] = Field(None, ge=0)
equip_amulet_id: Optional[int] = Field(None, ge=0)
equip_torso_id: Optional[int] = Field(None, ge=0)
equip_legs_id: Optional[int] = Field(None, ge=0)
equip_boots_id: Optional[int] = Field(None, ge=0)
equip_cape_id: Optional[int] = Field(None, ge=0)
equip_hands_id: Optional[int] = Field(None, ge=0)
equip_weapon_id: Optional[int] = Field(None, ge=0)
equip_shield_id: Optional[int] = Field(None, ge=0)


class Detection(BaseModel):
Expand Down
Loading

0 comments on commit f305f7b

Please sign in to comment.