Skip to content

Commit 05c433d

Browse files
awoodskimpham54
authored andcommitted
Isolate unit and int tests
Add GitHub Actions for tests and style - comment out flake8... until style issues initially resolved - comment out coverage comparison... until tests merged to `main
1 parent f4cf446 commit 05c433d

File tree

8 files changed

+100
-2
lines changed

8 files changed

+100
-2
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
input/*
2+
output/*

.github/workflows/test.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Tests and Style
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
python-version: [3.11.4]
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Switch to Current Branch
19+
run: git checkout ${{ env.BRANCH }}
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -r requirements.txt
30+
pip install -e .
31+
32+
# - name: Run flake8
33+
# run: |
34+
# pip install flake8
35+
# # stop the build if there are flake8 errors
36+
# flake8 . --count --show-source --statistics
37+
38+
- name: Run unit tests
39+
run: |
40+
pip install pytest
41+
python -m pytest src/jp2_remediator/tests/unit
42+
43+
- name: Run coverage
44+
run: |
45+
pip install coverage
46+
python -m coverage run -p -m pytest src/jp2_remediator/tests/unit
47+
python -m coverage combine
48+
python -m coverage report -m --skip-covered
49+
python -m coverage xml
50+
51+
# # Fetch base branch for comparison (e.g., main)
52+
# - name: Fetch base branch
53+
# run: git fetch origin main
54+
55+
# # Compare coverage with the base branch
56+
# - name: Compare coverage
57+
# run: |
58+
# git checkout main
59+
# python -m coverage run -p -m pytest src/jp2_remediator/tests/unit
60+
# python -m coverage xml -o coverage-base.xml
61+
# git checkout -
62+
# python -m diff-cover --compare-branch=main coverage.xml
63+
64+
# # Fail if coverage decreases
65+
# - name: Fail if coverage decreases
66+
# run: python -m diff-cover --compare-branch=main coverage.xml --fail-under=100
67+

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
*~
22
*.swp
3+
input/*
4+
output/*
5+
.coverage
6+
coverage.*
37

48
dist/*
59
*/*.egg-info/*
610
__pycache__
7-
.DS_Store
11+
.DS_Store

pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ dependencies = []
2121
[project.urls]
2222
Homepage = "https://github.com/kimpham54/jp2_remediator"
2323
Issues = "https://github.com/kimpham54/jp2_remediator/issues"
24+
25+
[tool.pytest.ini_options]
26+
pythonpath = [
27+
".", "src"
28+
]
29+
30+
[tool.coverage.run]
31+
omit = [
32+
"**/tests/*"
33+
]
34+
35+
[tool.project-paths]
36+
dir_unit_out = "src/jp2_remediator/tests/out/"
37+
dir_unit_resources = "src/jp2_remediator/tests/resources/"

requirements.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
boto3==1.35.39
2+
botocore==1.35.39
3+
jmespath==1.0.1
4+
jpylyzer==2.2.1
5+
project-paths==1.1.1
6+
python-dateutil==2.9.0.post0
7+
s3transfer==0.10.3
8+
six==1.16.0
9+
toml==0.10.2
10+
urllib3==2.2.3

src/jp2_remediator/tests/test_box_reader.py src/jp2_remediator/tests/unit/test_box_reader.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from unittest.mock import patch, mock_open
44
from jp2_remediator.box_reader import BoxReader
55
from jpylyzer import boxvalidator
6+
from project_paths import paths
67
import datetime
78

89
# Define the path to the test data file
9-
TEST_DATA_PATH = os.path.join(os.path.dirname(__file__), 'sample.jp2')
10+
TEST_DATA_PATH = os.path.join(paths.dir_unit_resources, 'sample.jp2')
1011

1112
class TestJP2ProcessingWithFile(unittest.TestCase):
1213

0 commit comments

Comments
 (0)