Skip to content

Commit 644778e

Browse files
committed
wip: test: add manual test instructions, tidy repo
Private-ref: https://tasks.opencraft.com/browse/BB-10035
1 parent 6a60578 commit 644778e

21 files changed

Lines changed: 130 additions & 245 deletions

.github/pull_request_template.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Description
2+
3+
Describe what this pull request changes, and why. Include implications for people using this change.
4+
5+
## Supporting information
6+
7+
Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
8+
Be sure to check they are publicly readable, or if not, repeat the information here.
9+
10+
## Testing instructions
11+
12+
Please provide detailed step-by-step instructions for testing this change.
13+
14+
## Deadline
15+
16+
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
17+
18+
## Other information
19+
20+
Include anything else that will help reviewers and consumers understand the change.
21+
22+
- Does this change depend on other changes elsewhere?
23+
- Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
24+
- If your [database migration](https://openedx.atlassian.net/wiki/spaces/AC/pages/23003228/Everything+About+Database+Migrations) can't be rolled back easily.
25+
26+
## Pre-merge checklist:
27+
28+
- [ ] `make format` has been run.
29+
- [ ] This has been manually installed in a Tutor devstack and manual testing steps have been followed (as described in the README).

Makefile

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,19 @@
22

33
.DEFAULT_GOAL := help
44

5-
# For opening files in a browser. Use like: $(BROWSER)relative/path/to/file.html
6-
BROWSER := python -m webbrowser file://$(CURDIR)/
7-
85
help: ## display this help message
96
@echo "Please use \`make <target>' where <target> is one of"
107
@awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
118

12-
clean: ## remove generated byte code, coverage reports, and build artifacts
9+
clean: ## remove generated byte code, build artifacts, etc.
1310
find . -name '__pycache__' -exec rm -rf {} +
1411
find . -name '*.pyc' -exec rm -f {} +
1512
find . -name '*.pyo' -exec rm -f {} +
1613
find . -name '*~' -exec rm -f {} +
17-
coverage erase
1814
rm -fr build/
1915
rm -fr dist/
2016
rm -fr *.egg-info
2117

22-
coverage: clean ## generate and view HTML coverage report
23-
pytest --cov-report html
24-
$(BROWSER)htmlcov/index.html
25-
2618
# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
2719
PIP_COMPILE = pip-compile --rebuild --upgrade $(PIP_COMPILE_OPTS)
2820

@@ -32,14 +24,10 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
3224
# Make sure to compile files after any other files they include!
3325
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
3426
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
35-
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
3627
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
3728
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
38-
# Let tox control the Django version for tests
39-
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
40-
mv requirements/test.tmp requirements/test.txt
4129

42-
quality: selfcheck ## check coding style with pycodestyle and pylint
30+
quality: selfcheck ## run static code quality checks
4331
tox -e quality
4432

4533
pii_check: ## check for PII annotations on all Django models
@@ -49,23 +37,12 @@ requirements: ## install development environment requirements
4937
pip install -qr requirements/pip-tools.txt
5038
pip-sync requirements/dev.txt requirements/private.*
5139

52-
test: clean ## run tests in the current virtualenv
53-
pytest
54-
55-
diff_cover: test ## find diff lines that need test coverage
56-
diff-cover coverage.xml
57-
58-
test-all: quality ## run tests on every supported Python/Django combination
59-
tox
60-
61-
validate: quality test ## run tests and quality checks
62-
6340
selfcheck: ## check that the Makefile is well-formed
6441
@echo "The Makefile is well-formed."
6542

43+
# NOTE: This needs to be run in an tutor dev environment
6644
test_migrations: ## check that Django migrations reflect all model changes
67-
tox -e migrations
45+
python ./manage.py makemigrations shoppingcart --check --dry-run --verbosity 3
6846

6947
format: ## apply standard code formatting
70-
isort shoppingcart setup.py manage.py tests test_utils test_settings.py
71-
black shoppingcart setup.py manage.py tests test_utils test_settings.py
48+
tox -e format

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,39 @@ Updated for standalone, Juniper/Py3 by @bryanlandia
1717

1818
See [apidocs.md](./appsembler_api/apidocs.md) for details on usage/the API
1919

20+
## Installing in a devstack
21+
22+
This assumes a [Tutor dev devstack](https://docs.tutor.edly.io/dev.html) set up.
23+
24+
```
25+
git clone https://github.com/open-craft/legacy-appsembler-api
26+
tutor mounts add ./legacy-appsembler-api
27+
28+
# This directory won't be autodetected for build-time mount by Tutor,
29+
# so we need to manually configure Tutor for it.
30+
mkdir -p "$TUTOR_PLUGINS_ROOT"
31+
echo 'from tutor import hooks; hooks.Filters.MOUNTED_DIRECTORIES.add_item(("openedx", "legacy-appsembler-api"))' > "$TUTOR_PLUGINS_ROOT/legacy-appsembler-api.py"
32+
tutor plugins enable legacy-appsembler-api
33+
34+
tutor images build openedx-dev
35+
tutor dev launch
36+
```
37+
2038
## Testing
2139

22-
For some tests you need to run them from within a working Open edX environment.
40+
Quality tests (runs within tox, so you can run it directly on your workstation):
41+
42+
```
43+
make quality
44+
```
45+
46+
---
47+
48+
For unit/integration tests and migration tests,
49+
you need to run them from within a working Open edX environment.
50+
Note that the tests will make changes to the database. They should be automatically rolled back,
51+
but just in case, it's only recommended to run on a test deployment.
52+
2353
Install in a Tutor devstack, then shell into the lms:
2454

2555
```sh
@@ -32,9 +62,9 @@ In the LMS shell, cd to the plugin directory:
3262
cd /mnt/legacy-appsembler-api
3363
```
3464

35-
Then you can run the unit tests (no unit tests yet):
65+
Then you can run the unit tests and migration tests:
3666

3767
```sh
38-
pytest
39-
python ./manage.py makemigrations shoppingcart --check --dry-run --verbosity 3
68+
make test
69+
make test_migrations
4070
```

codecov.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[tool.black]
22
line-length = 120
3+
4+
[tool.isort]
5+
profile = "black"

requirements/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# make upgrade
66
#
7-
asgiref==3.9.1
7+
asgiref==3.9.2
88
# via django
99
django==4.2.24
1010
# via

requirements/dev.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
-r pip-tools.txt # pip-tools and its dependencies, for managing requirements files
55
-r quality.txt # Core and quality check dependencies
66

7-
diff-cover # Changeset diff test coverage
87
edx-i18n-tools # For i18n_tool dummy
98
tox-battery # Makes tox aware of requirements file changes

requirements/dev.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# make upgrade
66
#
7-
asgiref==3.9.1
7+
asgiref==3.9.2
88
# via
99
# -r requirements/quality.txt
1010
# django
@@ -62,7 +62,7 @@ cryptography==46.0.1
6262
# via
6363
# -r requirements/quality.txt
6464
# secretstorage
65-
diff-cover==9.6.0
65+
diff-cover==9.7.0
6666
# via -r requirements/dev.in
6767
dill==0.4.0
6868
# via
@@ -86,6 +86,12 @@ edx-i18n-tools==1.9.0
8686
# via -r requirements/dev.in
8787
edx-lint==5.6.0
8888
# via -r requirements/quality.txt
89+
factory-boy==3.3.3
90+
# via -r requirements/quality.txt
91+
faker==37.8.0
92+
# via
93+
# -r requirements/quality.txt
94+
# factory-boy
8995
filelock==3.19.1
9096
# via
9197
# tox
@@ -324,6 +330,10 @@ tox-battery==0.6.2
324330
# via -r requirements/dev.in
325331
twine==6.2.0
326332
# via -r requirements/quality.txt
333+
tzdata==2025.2
334+
# via
335+
# -r requirements/quality.txt
336+
# faker
327337
urllib3==2.5.0
328338
# via
329339
# -r requirements/quality.txt

requirements/quality.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
black
77
edx-lint # edX pylint rules and plugins
88
isort # to standardize order of imports
9-
pycodestyle # PEP 8 compliance validation
10-
pydocstyle # PEP 257 compliance validation
119
pylint
1210
twine # Utility for publishing Python packages on PyPI.

requirements/quality.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# make upgrade
66
#
7-
asgiref==3.9.1
7+
asgiref==3.9.2
88
# via
99
# -r requirements/test.txt
1010
# django
@@ -54,6 +54,12 @@ docutils==0.22.2
5454
# via readme-renderer
5555
edx-lint==5.6.0
5656
# via -r requirements/quality.in
57+
factory-boy==3.3.3
58+
# via -r requirements/test.txt
59+
faker==37.8.0
60+
# via
61+
# -r requirements/test.txt
62+
# factory-boy
5763
id==1.5.0
5864
# via twine
5965
idna==3.10
@@ -200,6 +206,10 @@ tomlkit==0.13.3
200206
# via pylint
201207
twine==6.2.0
202208
# via -r requirements/quality.in
209+
tzdata==2025.2
210+
# via
211+
# -r requirements/test.txt
212+
# faker
203213
urllib3==2.5.0
204214
# via
205215
# requests

0 commit comments

Comments
 (0)