Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement tests #11

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/development-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This workflow runs tests on all non-master branches to ensure code stability and quality before merging.

name: Run Tests

on:
push:
branches-ignore:
- master

jobs:
test:
uses: ./.github/workflows/test.yml
17 changes: 10 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:
branches: [ master ]

jobs:
test:
if: contains(github.event.head_commit.message, 'chore(release)')
uses: ./.github/workflows/test.yml

build:
needs: test
if: contains(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-22.04
steps:
Expand All @@ -24,13 +29,13 @@ jobs:

- name: Install pypa/build
run: >-
python3 -m
python -m
pip install
build
--user

- name: Build a binary wheel and a source tarball
run: python3 -m build
run: python -m build

- name: Store the distribution packages
uses: actions/[email protected]
Expand All @@ -41,8 +46,7 @@ jobs:
publish-to-test-pypi:
name: >-
Publish to Test PyPI
needs:
- build
needs: build
if: contains(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-22.04

Expand All @@ -68,8 +72,7 @@ jobs:
publish-to-pypi:
name: >-
Publish to PyPI
needs:
- publish-to-test-pypi
needs: publish-to-test-pypi
if: contains(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-22.04

Expand All @@ -88,4 +91,4 @@ jobs:
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
uses: pypa/gh-action-pypi-publish@release/v1.8
4 changes: 4 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ permissions:
name: release-please

jobs:
test:
uses: ./.github/workflows/test.yml

release-please:
runs-on: ubuntu-22.04
needs: test
steps:
- uses: google-github-actions/[email protected]
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python Tests

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/[email protected]

- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -r requirements.txt

- name: Run tests
run: |
python -m unittest discover -s ./tests/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# buttercms-python - 2.1.1 <!-- {x-release-please-version} -->

[![PyPI version](https://badge.fury.io/py/buttercms-python.svg)](https://badge.fury.io/py/buttercms-python)
[![TestPyPI version](https://img.shields.io/pypi/v/buttercms-python?label=TestPyPI)](https://test.pypi.org/project/buttercms-python/)
[![Downloads](https://pepy.tech/badge/buttercms-python)](https://pepy.tech/project/buttercms-python)
[![Downloads](https://pepy.tech/badge/buttercms-python/month)](https://pepy.tech/project/buttercms-python)
[![Downloads](https://pepy.tech/badge/buttercms-python/week)](https://pepy.tech/project/buttercms-python)

Python Library for ButterCMS API.

> [!IMPORTANT]
> We officially support Python versions 3.8 to 3.12. While compatibility with other Python 3.x versions is possible, as we currently do not utilize any version-specific features, it is not guaranteed.

## Documentation

For a comprehensive list of examples, check out the [API documentation](https://buttercms.com/docs/api/).
Expand Down
15 changes: 14 additions & 1 deletion butter_cms/content_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@ def __init__(self, auth_token):
Client.__init__(self, auth_token)
self.path = 'content/'

def get(self, keys=None, params=None):
def get(self, keys, params=None):
if not params:
params = {}
params['keys'] = ','.join(keys)
return self.api_get(params=params)

def get_collection(self, slug, fields=None, params=None):
if not params:
params = {}
if fields:
for field_dict in fields:
for key, value in field_dict.items():
param_key = f"fields.{key}"
params[param_key] = value

full_slug = f'{slug}/'

return self.api_get(slug=full_slug, params=params)
160 changes: 0 additions & 160 deletions butter_cms/unit_tests.py

This file was deleted.

1 change: 0 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"last-release-sha": "426e26596b25b8fe517ff6a4a19fa745a0e2f2f9",
"packages": {
".": {
"release-type": "python",
Expand Down
31 changes: 23 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
build==1.2.1
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.7
packaging==24.0
pyproject_hooks==1.0.0
requests==2.31.0
urllib3==2.2.1
# dependecies required for python versions 3.8 - 3.12
build==1.2.1; python_version >= '3.8'
certifi==2024.2.2; python_version >= '3.8'
charset-normalizer==3.3.2; python_version >= '3.8'
idna==3.7; python_version >= '3.8'
packaging==24.0; python_version >= '3.8'
pyproject_hooks==1.1.0; python_version >= '3.8'
requests==2.31.0; python_version >= '3.8'
# dependecies required for testing (due to vcrpy)
multidict==6.0.5; python_version >= '3.8'
PyYAML==6.0.1; python_version >= '3.8'
vcrpy==6.0.1; python_version >= '3.8'
wrapt==1.16.0; python_version >= '3.8'
yarl==1.9.4; python_version >= '3.8'

# dependecies required for python versions 3.8 - 3.10
importlib_metadata==7.1.0; python_version == '3.8' or python_version == '3.9'
tomli==2.0.1; python_version == '3.8' or python_version == '3.9' or python_version == '3.10'
zipp==3.18.1; python_version == '3.8' or python_version == '3.9'

# other dependecies
urllib3==2.2.1; python_version >= '3.10'
urllib3==1.26.18; python_version == '3.8' or python_version == '3.9' # conflicting with vcrpy on these versions
14 changes: 1 addition & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import os

try:
Expand All @@ -9,17 +8,7 @@
with open('README.md', 'r') as f:
readme = f.read()

install_requires = []
if sys.version_info < (2, 7, 9):
raise Exception('ButterCMS uses the requests library to securely talk to https://buttercms.com '
'which requires Python 2.7.9 or later.\n'
'Please take a few seconds to upgrade to Python 2.7.9 and try again.\n'
'https://www.python.org/downloads/')
# TODO: Add support for < Python 2.7.9
# install_requires.append('requests[security]')
else:
install_requires.append('requests')

install_requires = ['requests']
package_root = os.path.abspath(os.path.dirname(__file__))
version = {}

Expand Down Expand Up @@ -48,7 +37,6 @@
'Environment :: Web Environment',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Framework :: Django',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
Expand Down
Empty file added tests/__init__.py
Empty file.
Loading