-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #2 from pomponchik/develop
0.0.2
- Loading branch information
Showing
9 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: tests | ||
|
||
on: | ||
push | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-latest] | ||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install the library | ||
shell: bash | ||
run: python setup.py install | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: pip install -r requirements_dev.txt | ||
|
||
- name: Run tests and show coverage on the command line | ||
run: coverage run --source=cbfa --omit="*tests*" -m pytest --cache-clear && coverage report -m | ||
|
||
- name: Upload reports to codecov | ||
env: | ||
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} | ||
if: runner.os == 'Linux' | ||
run: | | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
find . -iregex "codecov.*" | ||
chmod +x codecov | ||
./codecov -t ${CODECOV_TOKEN} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ __pycache__ | |
*.egg-info | ||
dist | ||
build | ||
venv | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
wheel==0.33.1 | ||
pip==19.0.3 | ||
twine==1.13.0 | ||
pyparsing>=2.0.2 | ||
pytest==7.4.2 | ||
coverage==7.2.7 | ||
twine==4.0.2 | ||
wheel==0.40.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,36 @@ | ||
from setuptools import setup, find_packages | ||
|
||
with open("README.md", "r") as readme_file: | ||
|
||
with open('README.md', 'r', encoding='utf8') as readme_file: | ||
readme = readme_file.read() | ||
|
||
requirements = [] | ||
|
||
setup( | ||
name="cbfa", | ||
version="0.0.1", | ||
author="Evgeniy Blinov", | ||
author_email="zheni-b@yandex.ru", | ||
description="Class-based views for the FastAPI", | ||
name='cbfa', | ||
version='0.0.2', | ||
author='Evgeniy Blinov', | ||
author_email='zheni-b@yandex.ru', | ||
description='Class-based views for the FastAPI', | ||
long_description=readme, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/pomponchik/cbfa", | ||
packages=find_packages(), | ||
long_description_content_type='text/markdown', | ||
url='https://github.com/pomponchik/cbfa', | ||
packages=find_packages(exclude='tests'), | ||
install_requires=requirements, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3.8", | ||
"License :: OSI Approved :: MIT License", | ||
'Operating System :: MacOS :: MacOS X', | ||
'Operating System :: Microsoft :: Windows', | ||
'Operating System :: POSIX', | ||
'Operating System :: POSIX :: Linux', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
'License :: OSI Approved :: MIT License', | ||
'Intended Audience :: Developers', | ||
'Topic :: Software Development :: Libraries', | ||
'Framework :: FastAPI', | ||
], | ||
) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
from cbfa import ClassBased | ||
|
||
|
||
class PseudoApp: | ||
def __init__(self): | ||
self.calls = [] | ||
|
||
def get(self, url): | ||
self.calls.append(('get', url)) | ||
return lambda x: x | ||
def post(self, url): | ||
self.calls.append(('post', url)) | ||
return lambda x: x | ||
def put(self, url): | ||
self.calls.append(('put', url)) | ||
return lambda x: x | ||
def delete(self, url): | ||
self.calls.append(('delete', url)) | ||
return lambda x: x | ||
def trace(self, url): | ||
self.calls.append(('trace', url)) | ||
return lambda x: x | ||
def head(self, url): | ||
self.calls.append(('head', url)) | ||
return lambda x: x | ||
def options(self, url): | ||
self.calls.append(('options', url)) | ||
return lambda x: x | ||
def connect(self, url): | ||
self.calls.append(('connect', url)) | ||
return lambda x: x | ||
def patch(self, url): | ||
self.calls.append(('patch', url)) | ||
return lambda x: x | ||
|
||
|
||
def test_wrap_only_get(): | ||
app = PseudoApp() | ||
wrapper = ClassBased(app) | ||
|
||
@wrapper('/kek') | ||
class SomeItem: | ||
def get(): | ||
pass | ||
|
||
assert app.calls == [('get', '/kek')] | ||
|
||
|
||
def test_wrap_all(): | ||
url = '/kek' | ||
app = PseudoApp() | ||
wrapper = ClassBased(app) | ||
|
||
@wrapper(url) | ||
class SomeItem: | ||
def get(): | ||
pass | ||
def post(): | ||
pass | ||
def put(): | ||
pass | ||
def delete(): | ||
pass | ||
def trace(): | ||
pass | ||
def head(): | ||
pass | ||
def options(): | ||
pass | ||
def connect(): | ||
pass | ||
def patch(): | ||
pass | ||
|
||
assert app.calls == [('get', url), ('post', url), ('put', url), ('delete', url), ('trace', url), ('head', url), ('options', url), ('connect', url), ('patch', url)] |