Skip to content

Commit

Permalink
Initial testing fixes (#485)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nickmoreton authored Jul 7, 2023
1 parent d4e1257 commit 33f0244
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 45 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ docs/_build

webpack-stats.json
*bundle.js*
.eggs/
.eggs/

# local virtual environment
/venv
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion longclaw/checkout/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="icon icon-doc-empty-inverse">
{% 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>
Expand All @@ -47,4 +47,4 @@ <h1 class="icon icon-doc-empty-inverse">
{% block extra_css %}
{{ block.super }}
{% include "wagtailadmin/pages/_editor_css.html" %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion longclaw/project_template/project_name/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',

'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

Expand Down
2 changes: 1 addition & 1 deletion longclaw/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
'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',
]

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

13 changes: 0 additions & 13 deletions requirements_dev.txt

This file was deleted.

29 changes: 24 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,47 @@ def get_version(*file_paths):
],
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',
classifiers=[
'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]
Expand Down
39 changes: 32 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 33f0244

Please sign in to comment.