From 0d9feb82e7bfb8a07eca21bff13a0bf2a9b19f67 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 00:58:39 +0300 Subject: [PATCH 01/18] badges in the readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 94e814e..b6621e8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ # cbfa +[![Downloads](https://static.pepy.tech/badge/cbfa/month)](https://pepy.tech/project/cbfa) +[![Downloads](https://static.pepy.tech/badge/cbfa)](https://pepy.tech/project/cbfa) +[![codecov](https://codecov.io/gh/pomponchik/cbfa/graph/badge.svg?token=O9G4FD8QFC)](https://codecov.io/gh/pomponchik/cbfa) +[![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) +[![Python versions](https://img.shields.io/pypi/pyversions/cbfa.svg)](https://pypi.python.org/pypi/cbfa) +[![PyPI version](https://badge.fury.io/py/cbfa.svg)](https://badge.fury.io/py/cbfa) + + Немного манки-патчинга для FastAPI, хендлеры на основе классов. Пока без поддержки ```self```. Устанавливаем: From 035852aae4a7a138924a9c72cc109a80cd9e7e03 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:15:40 +0300 Subject: [PATCH 02/18] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9dec8c5..c13852e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ __pycache__ *.egg-info dist build +venv From d584e5f7002a9a00b950c646d43fe6ebe130d778 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:27:14 +0300 Subject: [PATCH 03/18] basic tests --- requirements_dev.txt | 1 + tests/__init__.py | 0 tests/smokes/__init__.py | 0 tests/units/__init__.py | 0 tests/units/test_class_based.py | 75 +++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/smokes/__init__.py create mode 100644 tests/units/__init__.py create mode 100644 tests/units/test_class_based.py diff --git a/requirements_dev.txt b/requirements_dev.txt index 7976afe..9bf6c7b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,3 +2,4 @@ wheel==0.33.1 pip==19.0.3 twine==1.13.0 pyparsing>=2.0.2 +pytest==7.4.2 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/smokes/__init__.py b/tests/smokes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/units/__init__.py b/tests/units/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/units/test_class_based.py b/tests/units/test_class_based.py new file mode 100644 index 0000000..a54ed49 --- /dev/null +++ b/tests/units/test_class_based.py @@ -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)] From dc99d9af1901eeffaacf1840721cc57a0130e191 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:28:35 +0300 Subject: [PATCH 04/18] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c13852e..0c329c4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ dist build venv +.pytest_cache From b20d781d29924466c5b5dd6ed7ca7b6d52bcbc05 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:45:19 +0300 Subject: [PATCH 05/18] CI --- .github/workflows/tests_and_coverage.yml | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/tests_and_coverage.yml diff --git a/.github/workflows/tests_and_coverage.yml b/.github/workflows/tests_and_coverage.yml new file mode 100644 index 0000000..1591554 --- /dev/null +++ b/.github/workflows/tests_and_coverage.yml @@ -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} From 002cea73e5106f4fbec3f7f6948b146f749b3240 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:46:58 +0300 Subject: [PATCH 06/18] quotation marks --- setup.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 0e65ed8..87246a9 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,23 @@ from setuptools import setup, find_packages -with open("README.md", "r") as readme_file: +with open('README.md', 'r') 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.1', + 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", + long_description_content_type='text/markdown', + url='https://github.com/pomponchik/cbfa', packages=find_packages(), install_requires=requirements, classifiers=[ - "Programming Language :: Python :: 3.8", - "License :: OSI Approved :: MIT License", + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', ], ) From 087cf3239763828d2ad374fd235a9ba191a49dbd Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:48:07 +0300 Subject: [PATCH 07/18] coverage --- requirements_dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_dev.txt b/requirements_dev.txt index 9bf6c7b..e608db2 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -3,3 +3,4 @@ pip==19.0.3 twine==1.13.0 pyparsing>=2.0.2 pytest==7.4.2 +coverage==7.2.7 From 6b81bcbc98b60467a23da3d24bf7805f7ee51466 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:49:06 +0300 Subject: [PATCH 08/18] readme badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6621e8..1b8c913 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Downloads](https://static.pepy.tech/badge/cbfa/month)](https://pepy.tech/project/cbfa) [![Downloads](https://static.pepy.tech/badge/cbfa)](https://pepy.tech/project/cbfa) -[![codecov](https://codecov.io/gh/pomponchik/cbfa/graph/badge.svg?token=O9G4FD8QFC)](https://codecov.io/gh/pomponchik/cbfa) +[![codecov](https://codecov.io/gh/pomponchik/cbfa/graph/badge.svg?token=7XDY2T7S68)](https://codecov.io/gh/pomponchik/cbfa) [![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) [![Python versions](https://img.shields.io/pypi/pyversions/cbfa.svg)](https://pypi.python.org/pypi/cbfa) [![PyPI version](https://badge.fury.io/py/cbfa.svg)](https://badge.fury.io/py/cbfa) From d9e87a1d757ca942cb72abde0778f64cdffe72b5 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:50:52 +0300 Subject: [PATCH 09/18] windows fix --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 87246a9..df517e8 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ 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 = [] From 992efbc6f900c460e1de9cd87641edd103958127 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:51:23 +0300 Subject: [PATCH 10/18] exclude --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index df517e8..7ea7b1e 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ long_description=readme, long_description_content_type='text/markdown', url='https://github.com/pomponchik/cbfa', - packages=find_packages(), + packages=find_packages(exclude='tests'), install_requires=requirements, classifiers=[ 'Programming Language :: Python :: 3.8', From 6f1d2ef0d2fa90e0e816461580818c8c3fd6b2f5 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:52:56 +0300 Subject: [PATCH 11/18] requirements --- requirements_dev.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index e608db2..0f96e07 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,6 +1,5 @@ -wheel==0.33.1 -pip==19.0.3 -twine==1.13.0 -pyparsing>=2.0.2 +wheel==0.41.2 +pip==23.2.1 +twine==4.0.2 pytest==7.4.2 coverage==7.2.7 From 414dba78c979ebc7eeb755841872db767856b755 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:55:24 +0300 Subject: [PATCH 12/18] requirements --- requirements_dev.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 0f96e07..f3c0107 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,5 +1,4 @@ -wheel==0.41.2 -pip==23.2.1 -twine==4.0.2 pytest==7.4.2 coverage==7.2.7 +twine==4.0.2 +wheel==0.40.0 From 9d6a0da3dd45c4aed45ab0bfbab48a8f18ba3019 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:56:43 +0300 Subject: [PATCH 13/18] python 3.12 --- .github/workflows/tests_and_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_and_coverage.yml b/.github/workflows/tests_and_coverage.yml index 1591554..9287f8a 100644 --- a/.github/workflows/tests_and_coverage.yml +++ b/.github/workflows/tests_and_coverage.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 From f688569fe53fcab0185864bafa7a1c3b101f75fb Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:57:50 +0300 Subject: [PATCH 14/18] without python 3.12 --- .github/workflows/tests_and_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_and_coverage.yml b/.github/workflows/tests_and_coverage.yml index 9287f8a..1591554 100644 --- a/.github/workflows/tests_and_coverage.yml +++ b/.github/workflows/tests_and_coverage.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v2 From b277d2478f029c8368fe8f96ffff6e725b298345 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:58:25 +0300 Subject: [PATCH 15/18] classifiers --- setup.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup.py b/setup.py index 7ea7b1e..b713dd6 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,18 @@ packages=find_packages(exclude='tests'), install_requires=requirements, classifiers=[ + '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', ], ) From 108c072c30542b2bf4c38dabb42e8bf8b2881c38 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:59:05 +0300 Subject: [PATCH 16/18] classifiers --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b713dd6..78a64a8 100644 --- a/setup.py +++ b/setup.py @@ -30,5 +30,6 @@ 'License :: OSI Approved :: MIT License', 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries', + 'Framework :: FastAPI', ], ) From add1afad17fb7d9ad0018de667654b01484a19e0 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 01:59:21 +0300 Subject: [PATCH 17/18] empty line --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 78a64a8..05f5fbb 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from setuptools import setup, find_packages + with open('README.md', 'r', encoding='utf8') as readme_file: readme = readme_file.read() From b9f67d53d11eda8fea8628ec94e22346dc23eaee Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Thu, 19 Oct 2023 02:00:35 +0300 Subject: [PATCH 18/18] new version tag --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05f5fbb..de463a3 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='cbfa', - version='0.0.1', + version='0.0.2', author='Evgeniy Blinov', author_email='zheni-b@yandex.ru', description='Class-based views for the FastAPI',