Skip to content

Commit 20ffba9

Browse files
authored
Add testing (#2)
1 parent e3c2252 commit 20ffba9

File tree

7 files changed

+150
-69
lines changed

7 files changed

+150
-69
lines changed

.github/workflows/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,24 @@ jobs:
2929
- name: Install pip dependencies
3030
run: poetry install
3131
- uses: pre-commit/[email protected]
32+
test:
33+
runs-on: ubuntu-20.04
34+
steps:
35+
- uses: actions/checkout@master
36+
- uses: actions/cache@v3
37+
with:
38+
path: ~/.local/share/virtualenvs
39+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-poetry-
42+
- uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.10'
45+
- name: Install poetry
46+
uses: abatilo/[email protected]
47+
with:
48+
poetry-version: '1.3.1'
49+
- name: Install pip dependencies
50+
run: poetry install
51+
- name: Run tests
52+
run: poetry run pytest

edge_addons_api/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from os import path
23

34
import requests
45

@@ -19,6 +20,9 @@ def __init__(self, options: Options):
1920
self.options = options
2021

2122
def submit(self, file_path: str, notes: str):
23+
if not path.exists(file_path):
24+
raise FileNotFoundError(f"Unable to locate file at {file_path}")
25+
2226
access_token = self._get_access_token()
2327
self._upload(file_path, access_token)
2428
self._publish(notes, access_token)

poetry.lock

Lines changed: 108 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ packages = [{include = "edge_addons_api"}]
1010
[tool.poetry.dependencies]
1111
python = "^3.10"
1212
requests = "^2.28.1"
13-
marshmallow-dataclass = "^8.5.10"
1413

1514

15+
[tool.poetry.group.dev.dependencies]
16+
pytest-socket = "^0.5.1"
17+
pytest = "^7.2.0"
18+
1619
[build-system]
1720
requires = ["poetry-core"]
1821
build-backend = "poetry.core.masonry.api"

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = --disable-socket

tests/__init__.py

Whitespace-only changes.

tests/test_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from unittest import TestCase
2+
3+
from edge_addons_api.client import Client, Options
4+
5+
6+
class ClientTest(TestCase):
7+
def test_submit_missing_file(self):
8+
client = Client(Options("", "", "", ""))
9+
10+
with self.assertRaises(FileNotFoundError):
11+
client.submit("/non/existent/path", "new version upload")

0 commit comments

Comments
 (0)