Skip to content

Commit 83c6a4e

Browse files
authored
Merge pull request #2 from pomponchik/develop
0.0.2
2 parents 28250cd + b9f67d5 commit 83c6a4e

9 files changed

Lines changed: 154 additions & 15 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: tests
2+
3+
on:
4+
push
5+
6+
jobs:
7+
build:
8+
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [macos-latest, ubuntu-latest, windows-latest]
13+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install the library
23+
shell: bash
24+
run: python setup.py install
25+
26+
- name: Install dependencies
27+
shell: bash
28+
run: pip install -r requirements_dev.txt
29+
30+
- name: Run tests and show coverage on the command line
31+
run: coverage run --source=cbfa --omit="*tests*" -m pytest --cache-clear && coverage report -m
32+
33+
- name: Upload reports to codecov
34+
env:
35+
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
36+
if: runner.os == 'Linux'
37+
run: |
38+
curl -Os https://uploader.codecov.io/latest/linux/codecov
39+
find . -iregex "codecov.*"
40+
chmod +x codecov
41+
./codecov -t ${CODECOV_TOKEN}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ __pycache__
88
*.egg-info
99
dist
1010
build
11+
venv
12+
.pytest_cache

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# cbfa
22

3+
[![Downloads](https://static.pepy.tech/badge/cbfa/month)](https://pepy.tech/project/cbfa)
4+
[![Downloads](https://static.pepy.tech/badge/cbfa)](https://pepy.tech/project/cbfa)
5+
[![codecov](https://codecov.io/gh/pomponchik/cbfa/graph/badge.svg?token=7XDY2T7S68)](https://codecov.io/gh/pomponchik/cbfa)
6+
[![Test-Package](https://github.com/pomponchik/cbfa/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/cbfa/actions/workflows/tests_and_coverage.yml)
7+
[![Python versions](https://img.shields.io/pypi/pyversions/cbfa.svg)](https://pypi.python.org/pypi/cbfa)
8+
[![PyPI version](https://badge.fury.io/py/cbfa.svg)](https://badge.fury.io/py/cbfa)
9+
10+
311
Немного манки-патчинга для FastAPI, хендлеры на основе классов. Пока без поддержки ```self```.
412

513
Устанавливаем:

requirements_dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
wheel==0.33.1
2-
pip==19.0.3
3-
twine==1.13.0
4-
pyparsing>=2.0.2
1+
pytest==7.4.2
2+
coverage==7.2.7
3+
twine==4.0.2
4+
wheel==0.40.0

setup.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11
from setuptools import setup, find_packages
22

3-
with open("README.md", "r") as readme_file:
3+
4+
with open('README.md', 'r', encoding='utf8') as readme_file:
45
readme = readme_file.read()
56

67
requirements = []
78

89
setup(
9-
name="cbfa",
10-
version="0.0.1",
11-
author="Evgeniy Blinov",
12-
author_email="zheni-b@yandex.ru",
13-
description="Class-based views for the FastAPI",
10+
name='cbfa',
11+
version='0.0.2',
12+
author='Evgeniy Blinov',
13+
author_email='zheni-b@yandex.ru',
14+
description='Class-based views for the FastAPI',
1415
long_description=readme,
15-
long_description_content_type="text/markdown",
16-
url="https://github.com/pomponchik/cbfa",
17-
packages=find_packages(),
16+
long_description_content_type='text/markdown',
17+
url='https://github.com/pomponchik/cbfa',
18+
packages=find_packages(exclude='tests'),
1819
install_requires=requirements,
1920
classifiers=[
20-
"Programming Language :: Python :: 3.8",
21-
"License :: OSI Approved :: MIT License",
21+
'Operating System :: MacOS :: MacOS X',
22+
'Operating System :: Microsoft :: Windows',
23+
'Operating System :: POSIX',
24+
'Operating System :: POSIX :: Linux',
25+
'Programming Language :: Python',
26+
'Programming Language :: Python :: 3.7',
27+
'Programming Language :: Python :: 3.8',
28+
'Programming Language :: Python :: 3.9',
29+
'Programming Language :: Python :: 3.10',
30+
'Programming Language :: Python :: 3.11',
31+
'License :: OSI Approved :: MIT License',
32+
'Intended Audience :: Developers',
33+
'Topic :: Software Development :: Libraries',
34+
'Framework :: FastAPI',
2235
],
2336
)

tests/__init__.py

Whitespace-only changes.

tests/smokes/__init__.py

Whitespace-only changes.

tests/units/__init__.py

Whitespace-only changes.

tests/units/test_class_based.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from cbfa import ClassBased
2+
3+
4+
class PseudoApp:
5+
def __init__(self):
6+
self.calls = []
7+
8+
def get(self, url):
9+
self.calls.append(('get', url))
10+
return lambda x: x
11+
def post(self, url):
12+
self.calls.append(('post', url))
13+
return lambda x: x
14+
def put(self, url):
15+
self.calls.append(('put', url))
16+
return lambda x: x
17+
def delete(self, url):
18+
self.calls.append(('delete', url))
19+
return lambda x: x
20+
def trace(self, url):
21+
self.calls.append(('trace', url))
22+
return lambda x: x
23+
def head(self, url):
24+
self.calls.append(('head', url))
25+
return lambda x: x
26+
def options(self, url):
27+
self.calls.append(('options', url))
28+
return lambda x: x
29+
def connect(self, url):
30+
self.calls.append(('connect', url))
31+
return lambda x: x
32+
def patch(self, url):
33+
self.calls.append(('patch', url))
34+
return lambda x: x
35+
36+
37+
def test_wrap_only_get():
38+
app = PseudoApp()
39+
wrapper = ClassBased(app)
40+
41+
@wrapper('/kek')
42+
class SomeItem:
43+
def get():
44+
pass
45+
46+
assert app.calls == [('get', '/kek')]
47+
48+
49+
def test_wrap_all():
50+
url = '/kek'
51+
app = PseudoApp()
52+
wrapper = ClassBased(app)
53+
54+
@wrapper(url)
55+
class SomeItem:
56+
def get():
57+
pass
58+
def post():
59+
pass
60+
def put():
61+
pass
62+
def delete():
63+
pass
64+
def trace():
65+
pass
66+
def head():
67+
pass
68+
def options():
69+
pass
70+
def connect():
71+
pass
72+
def patch():
73+
pass
74+
75+
assert app.calls == [('get', url), ('post', url), ('put', url), ('delete', url), ('trace', url), ('head', url), ('options', url), ('connect', url), ('patch', url)]

0 commit comments

Comments
 (0)