Skip to content

Commit e3cfeac

Browse files
committed
wip: update and add tests
Private-ref: https://tasks.opencraft.com/browse/BB-10035
1 parent 1d396a5 commit e3cfeac

16 files changed

Lines changed: 638 additions & 366 deletions

File tree

.github/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches:
8+
- '**'
9+
10+
11+
jobs:
12+
tests:
13+
name: tests
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: setup python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: "3.11"
23+
24+
- name: Install Dependencies
25+
run: make requirements
26+
27+
- name: Run quality tests
28+
run: make quality
29+
30+
- name: Run migration checks
31+
run: make test_migrations

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pip-log.txt
3232
coverage.xml
3333
htmlcov/
3434

35-
35+
# virtual envs
36+
.venv
37+
venv
3638

3739
# The Silver Searcher
3840
.agignore

Makefile

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.PHONY: clean compile_translations coverage diff_cover docs dummy_translations \
2-
extract_translations fake_translations help pii_check pull_translations push_translations \
3-
quality requirements selfcheck test test-all upgrade validate
1+
.PHONY: clean coverage diff_cover pii_check help quality requirements selfcheck test test-all upgrade validate test_migrations
42

53
.DEFAULT_GOAL := help
64

@@ -25,29 +23,23 @@ coverage: clean ## generate and view HTML coverage report
2523
pytest --cov-report html
2624
$(BROWSER)htmlcov/index.html
2725

28-
docs: ## generate Sphinx HTML documentation, including API docs
29-
tox -e docs
30-
$(BROWSER)docs/_build/html/index.html
31-
3226
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
3327
PIP_COMPILE = pip-compile --rebuild --upgrade $(PIP_COMPILE_OPTS)
3428

3529
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
3630
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
37-
pip install -qr requirements/pip-tools.txt
31+
pip install -U -qr requirements/pip-tools.in
3832
# Make sure to compile files after any other files they include!
3933
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
4034
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
4135
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
42-
$(PIP_COMPILE) -o requirements/doc.txt requirements/doc.in
4336
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
44-
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
4537
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
4638
# Let tox control the Django version for tests
4739
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
4840
mv requirements/test.tmp requirements/test.txt
4941

50-
quality: ## check coding style with pycodestyle and pylint
42+
quality: selfcheck ## check coding style with pycodestyle and pylint
5143
tox -e quality
5244

5345
pii_check: ## check for PII annotations on all Django models
@@ -63,36 +55,13 @@ test: clean ## run tests in the current virtualenv
6355
diff_cover: test ## find diff lines that need test coverage
6456
diff-cover coverage.xml
6557

66-
test-all: quality pii_check ## run tests on every supported Python/Django combination
58+
test-all: quality ## run tests on every supported Python/Django combination
6759
tox
6860

69-
validate: quality pii_check test ## run tests and quality checks
61+
validate: quality test ## run tests and quality checks
7062

7163
selfcheck: ## check that the Makefile is well-formed
7264
@echo "The Makefile is well-formed."
7365

74-
## Localization targets
75-
76-
extract_translations: ## extract strings to be translated, outputting .mo files
77-
rm -rf docs/_build
78-
cd shoppingcart && ../manage.py makemessages -l en -v1 -d django
79-
cd shoppingcart && ../manage.py makemessages -l en -v1 -d djangojs
80-
81-
compile_translations: ## compile translation files, outputting .po files for each supported language
82-
cd shoppingcart && ../manage.py compilemessages
83-
84-
detect_changed_source_translations:
85-
cd shoppingcart && i18n_tool changed
86-
87-
pull_translations: ## pull translations from Transifex
88-
tx pull -af --mode reviewed
89-
90-
push_translations: ## push source translation files (.po) from Transifex
91-
tx push -s
92-
93-
dummy_translations: ## generate dummy translation (.po) files
94-
cd shoppingcart && i18n_tool dummy
95-
96-
build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files
97-
98-
validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations
66+
test_migrations: ## check that Django migrations reflect all model changes
67+
tox -e migrations

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# issue is really that Django is missing to avoid masking other
1919
# exceptions on Python 2.
2020
try:
21-
import django # pylint: disable=unused-import, wrong-import-position
21+
import django # pylint: disable=unused-import
2222
except ImportError as import_error:
2323
raise ImportError(
2424
"Couldn't import Django. Are you sure it's installed and "

mise.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[env]
2+
# --seed instructs uv to include pip, setuptools, and wheel in the resulting venv
3+
# useful for compatibility with other scripts that call pip
4+
_.python.venv = { path = ".venv", create = true, uv_create_args = ['--seed'] }
5+
6+
[tools]
7+
python = "3.11"

0 commit comments

Comments
 (0)