Initial testing fixes (#485)

* Test py 37,38,39 (#1) dj 22 wt 211,212,213

* Fixes the template include issue with the lock/unlock menu item

* Pin the upper bound of the supported Wagtail version to 2.13 and Django to 2.2

* Add some initial documentation for development setup
pull/488/head
Nick Moreton 2023-07-07 15:00:12 +02:00 zatwierdzone przez GitHub
rodzic d4e1257033
commit 33f02445ef
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
13 zmienionych plików z 155 dodań i 45 usunięć

56
.github/workflows/test.yml vendored 100644
Wyświetl plik

@ -0,0 +1,56 @@
name: Tests
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test-python:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.8", "3.9"]
steps:
- uses: actions/checkout@v2
- name: Install NPM and dependencies
uses: actions/setup-node@v2
with:
node-version: '12.x'
- name: Build client
run: |
npm install --prefix ./longclaw/client
npm run build --prefix ./longclaw/client
- name: Upload client
uses: actions/upload-artifact@v2
with:
name: client
path: ./longclaw/core/static/core/js
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Download client
uses: actions/download-artifact@v2
with:
name: client
path: ./longclaw/core/static/core/js
- name: Test with tox
run: tox

5
.gitignore vendored
Wyświetl plik

@ -53,4 +53,7 @@ docs/_build
webpack-stats.json
*bundle.js*
.eggs/
.eggs/
# local virtual environment
/venv

1
.python-version 100644
Wyświetl plik

@ -0,0 +1 @@
3.7

Wyświetl plik

@ -31,13 +31,13 @@ lint: ## check style with flake8
flake8 longclaw tests
test: ## run tests quickly with the default Python
python runtests.py tests
python runtests.py
test-all: ## run tests on every Python version with tox
tox
coverage: ## check code coverage quickly with the default Python
coverage run --source longclaw runtests.py tests
coverage run --source longclaw runtests.py
coverage report -m
coverage html
open htmlcov/index.html

Wyświetl plik

@ -1,7 +1,7 @@
# Longclaw
## Call For Maintainers
If you are interested in developing this project, please get in touch
https://github.com/JamesRamm/longclaw/issues/375
@ -12,8 +12,6 @@ https://github.com/JamesRamm/longclaw/issues/375
An e-commerce extension for [Wagtail CMS](https://github.com/wagtail/wagtail)
Checkout the [documentation](https://longclawshop.github.io/longclaw/)
![Image of the dashboard](docs/assets/dashboard.png)
@ -23,28 +21,28 @@ Checkout the [documentation](https://longclawshop.github.io/longclaw/)
Install Longclaw:
```bash
$ pip install longclaw
pip install longclaw
```
Setup a Longclaw project
```bash
$ longclaw start my_project
longclaw start my_project
```
Go to project directory and create missing migrations
```bash
$ python manage.py makemigrations home catalog
python manage.py makemigrations home catalog
```
Do migrations for whole project and run
```bash
$ python manage.py migrate
$ python manage.py loadcountries
$ python manage.py createsuperuser
$ python manage.py runserver
python manage.py migrate
python manage.py loadcountries
python manage.py createsuperuser
python manage.py runserver
```
## Features
@ -61,5 +59,28 @@ Do migrations for whole project and run
![Order Detail](docs/assets/order_detail.png)
## Development setup
Work in progress!
This is a brief guide to setting up a development environment for Longclaw.
Create a virtualenv and install the requirements
```bash
python3 -m venv venv
source venv/bin/activate
pip install -e ".[testing]"
```
Run the tests
```bash
make test
```
Run the tests with TOX
```bash
make test-all
```

Wyświetl plik

@ -1,7 +1,7 @@
from decimal import Decimal
from django.utils.module_loading import import_string
from django.utils import timezone
from ipware.ip import get_client_ip
from ipware import get_client_ip
from longclaw.basket.utils import get_basket_items, destroy_basket
from longclaw.shipping.utils import get_shipping_cost

Wyświetl plik

@ -21,7 +21,7 @@
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
{% include "wagtailadmin/pages/_privacy_switch.html" with page=page page_perms=page_perms only %}
{% include "wagtailadmin/pages/_lock_switch.html" %}
{% include "wagtailadmin/pages/action_menu/lock_unlock_menu_item.html" %}
</div>
</div>
</header>
@ -47,4 +47,4 @@
{% block extra_css %}
{{ block.super }}
{% include "wagtailadmin/pages/_editor_css.html" %}
{% endblock %}
{% endblock %}

Wyświetl plik

@ -64,7 +64,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

Wyświetl plik

@ -66,7 +66,7 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

Wyświetl plik

@ -1,2 +0,0 @@
--index-url https://pypi.python.org/simple/
-e .

Wyświetl plik

@ -1,13 +0,0 @@
-r requirements.txt
bumpversion==0.6.0
wheel==0.38.1
setuptools==65.5.1
coverage>=4.5.2
mock>=2.0.0
flake8>=3.6.0
tox>=3.5.3
codecov>=2.0.15
# Additional test requirements go here
factory_boy>=2.11.1
wagtail-factories>=1.1.0

Wyświetl plik

@ -87,14 +87,30 @@ setup(
],
include_package_data=True,
install_requires=[
'django==2.2.28',
'wagtail==2.11.8',
'django>=2.2,<3.0',
'wagtail>=2.11,<2.14',
'django-countries==5.5',
'django-extensions==2.2.1',
'djangorestframework==3.11.2',
'django-ipware==2.1.0',
'django-polymorphic==2.0.3',
],
extras_require={
"testing": [
"bumpversion==0.6.0",
"wheel==0.38.1",
"setuptools==65.5.1",
"coverage>=4.5.2",
"mock==2.0.0",
"flake8>=3.6.0",
"tox>=3.5.3",
"codecov>=2.0.15",
"# Additional test requirements go here",
"factory_boy>=2.11.1",
"wagtail-factories>=1.1.0",
],
},
license="MIT",
zip_safe=False,
keywords='longclaw',
@ -102,13 +118,16 @@ setup(
'Development Status :: 3 - Alpha',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Wagtail',
'Framework :: Wagtail :: 2',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.8'
'Programming Language :: Python :: 3.9'
'Programming Language :: Python :: 3.10'
],
entry_points="""
[console_scripts]

39
tox.ini
Wyświetl plik

@ -1,15 +1,40 @@
[tox]
skipsdist = True
usedevelop = True
skip_missing_interpreters = True
envlist =
{py35,py36,py37}-django-225
py{37,38,39}-dj{22}-wt{211,212,213}
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/longclaw
commands = coverage run --source longclaw runtests.py
coverage xml --omit=*/apps.py,*/migrations/*,*/__init__.py,*/gateways/braintree.py,*/gateways/stripe.py,*/bin/longclaw.py
deps =
django-225: Django==2.2.5
-r{toxinidir}/requirements_dev.txt
coverage
django-extensions
django-polymorphic
django-ipware
mock
wagtail-factories
dj22: Django>=2.2,<3.0
dj30: Django>=3.0,<3.1
wt211: wagtail>=2.11,<2.12
wt212: wagtail>=2.12,<2.13
wt213: wagtail>=2.13,<2.14
install_command = pip install -U {opts} {packages}
commands =
coverage run --source longclaw runtests.py
coverage xml --omit=*/apps.py,*/migrations/*,*/__init__.py,*/gateways/braintree.py,*/gateways/stripe.py,*/bin/longclaw.py
basepython =
py37: python3.7
py36: python3.6
py35: python3.5