Skip to content

Commit

Permalink
Set up tox, add a workflow to run tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cerrussell committed Jan 19, 2024
1 parent b5ce77b commit 59bb897
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Python matrix CI

on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
- 'dockertests.yml'
- 'dockertests.yml'
- 'python-publish.yml'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools
python3 -m pip install .[dev]
- name: Tox
run: |
python3 -m tox
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dev = [
"isort",
"pre-commit",
"pylint",
"pytest",
"tox",
]

Expand Down
4 changes: 2 additions & 2 deletions test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_openapi_class():
openapi = OpenAPI('openapi3.1.0', 'java',
'data/java-piggymetrics-usages.json')
'test/data/java-piggymetrics-usages.json')
assert openapi.openapi_version == '3.1.0'
assert openapi.origin_type == 'java'
assert openapi.endpoints_to_openapi() == {
Expand All @@ -18,7 +18,7 @@ def test_openapi_class():
'/uaa/users', '/{accountName}',
'/{name}']

openapi = OpenAPI('openapi3.0.1', 'java', 'data/java-sec-code-usages.json')
openapi = OpenAPI('openapi3.0.1', 'java', 'test/data/java-sec-code-usages.json')
assert openapi.openapi_version == '3.0.1'
assert openapi.origin_type == 'java'
assert openapi.endpoints_to_openapi() == {
Expand Down
4 changes: 2 additions & 2 deletions test/test_slices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


def test_usages_class():
usages = UsageSlice('data/java-piggymetrics-usages.json', 'java')
usages = UsageSlice('test/data/java-piggymetrics-usages.json', 'java')
assert usages.language == 'java'
result = usages.generate_endpoints()
result.sort()
assert result == ['/', '/accounts/{accountName}', '/current', '/latest',
'/statistics/{accountName}', '/uaa/users',
'/{accountName}', '/{name}']

usages = UsageSlice('data/java-sec-code-usages.json', 'java')
usages = UsageSlice('test/data/java-sec-code-usages.json', 'java')
assert usages.language == 'java'
result = usages.generate_endpoints()
result.sort()
Expand Down
7 changes: 7 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[tox]
minversion = 4.0
envlist = py310, py311, py312

[testenv]
deps = pytest
commands = pytest test

0 comments on commit 59bb897

Please sign in to comment.