Skip to content

Commit 18fdacf

Browse files
fix: update to use local app/ dir (#1872)
* fix: update to use local app/ dir * fix: update if statement on macos xlarge
1 parent 206148c commit 18fdacf

File tree

6 files changed

+55
-5
lines changed

6 files changed

+55
-5
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
with:
1717
submodules: "true"
1818
- name: Install dependencies
19-
run: pip install -r src/scripts/app/requirements.txt
19+
run: pip install -r app/requirements.txt
2020
- name: Run tests and collect coverage
21-
run: pytest src/scripts/app/ --cov
21+
run: pytest app/ --cov
2222

2323
- name: Upload coverage to Codecov (script)
2424
uses: ./
@@ -50,17 +50,17 @@ jobs:
5050
token: ${{ secrets.CODECOV_TOKEN }}
5151

5252
run-macos-latest-xlarge:
53-
if: github.head.repo.full_name == 'codecov/codecov-action'
53+
if: github.event.pull_request.head.repo.full_name == 'codecov/codecov-action'
5454
runs-on: macos-latest-xlarge
5555
steps:
5656
- name: Checkout
5757
uses: actions/[email protected]
5858
with:
5959
submodules: "true"
6060
- name: Install dependencies
61-
run: pip install -r src/scripts/app/requirements.txt
61+
run: pip install -r app/requirements.txt
6262
- name: Run tests and collect coverage
63-
run: pytest src/scripts/app/ --cov
63+
run: pytest app/ --cov
6464
- name: Upload coverage to Codecov (script)
6565
uses: ./
6666
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ public/
9393

9494
# macOS Finder metadata
9595
.DS_Store
96+
97+
# pycache dirs
98+
__pycache__/

app/__init__.py

Whitespace-only changes.

app/calculator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Calculator:
2+
3+
def add(x, y):
4+
return x + y
5+
6+
def subtract(x, y):
7+
return x - y
8+
9+
def multiply(x, y):
10+
return x * y
11+
12+
def divide(x, y):
13+
if y == 0:
14+
return 'Cannot divide by 0'
15+
return x * 1.0 / y

app/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-cov

app/test_calculator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from .calculator import Calculator
2+
3+
4+
def test_add():
5+
assert Calculator.add(1, 2) == 3.0
6+
assert Calculator.add(1.0, 2.0) == 3.0
7+
assert Calculator.add(0, 2.0) == 2.0
8+
assert Calculator.add(2.0, 0) == 2.0
9+
assert Calculator.add(-4, 2.0) == -2.0
10+
11+
def test_subtract():
12+
assert Calculator.subtract(1, 2) == -1.0
13+
assert Calculator.subtract(2, 1) == 1.0
14+
assert Calculator.subtract(1.0, 2.0) == -1.0
15+
assert Calculator.subtract(0, 2.0) == -2.0
16+
assert Calculator.subtract(2.0, 0.0) == 2.0
17+
assert Calculator.subtract(-4, 2.0) == -6.0
18+
19+
def test_multiply():
20+
assert Calculator.multiply(1, 2) == 2.0
21+
assert Calculator.multiply(1.0, 2.0) == 2.0
22+
assert Calculator.multiply(0, 2.0) == 0.0
23+
assert Calculator.multiply(2.0, 0.0) == 0.0
24+
assert Calculator.multiply(-4, 2.0) == -8.0
25+
26+
def test_divide():
27+
# assert Calculator.divide(1, 2) == 0.5
28+
assert Calculator.divide(1.0, 2.0) == 0.5
29+
assert Calculator.divide(0, 2.0) == 0
30+
assert Calculator.divide(-4, 2.0) == -2.0
31+
# assert Calculator.divide(2.0, 0.0) == 'Cannot divide by 0'

0 commit comments

Comments
 (0)