Skip to content
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
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

29 changes: 0 additions & 29 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/issue_template.md

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize]


jobs:
tests:
name: tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.11"

- name: Install tox
run: |
pip install "tox<5"

- name: Run quality tests
run: make quality
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ pip-log.txt
coverage.xml
htmlcov/


# virtual envs
.venv
venv

# The Silver Searcher
.agignore
Expand Down
47 changes: 10 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.PHONY: clean compile_translations coverage diff_cover docs dummy_translations \
extract_translations fake_translations help pii_check pull_translations push_translations \
quality requirements selfcheck test test-all upgrade validate
.PHONY: clean coverage diff_cover pii_check help quality requirements selfcheck test test-all upgrade validate test_migrations format

.DEFAULT_GOAL := help

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

docs: ## generate Sphinx HTML documentation, including API docs
tox -e docs
$(BROWSER)docs/_build/html/index.html

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --rebuild --upgrade $(PIP_COMPILE_OPTS)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
pip install -U -qr requirements/pip-tools.in
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/doc.txt requirements/doc.in
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
# Let tox control the Django version for tests
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt

quality: ## check coding style with pycodestyle and pylint
quality: selfcheck ## check coding style with pycodestyle and pylint
tox -e quality

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

test-all: quality pii_check ## run tests on every supported Python/Django combination
test-all: quality ## run tests on every supported Python/Django combination
tox

validate: quality pii_check test ## run tests and quality checks
validate: quality test ## run tests and quality checks

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

## Localization targets

extract_translations: ## extract strings to be translated, outputting .mo files
rm -rf docs/_build
cd shoppingcart && ../manage.py makemessages -l en -v1 -d django
cd shoppingcart && ../manage.py makemessages -l en -v1 -d djangojs

compile_translations: ## compile translation files, outputting .po files for each supported language
cd shoppingcart && ../manage.py compilemessages

detect_changed_source_translations:
cd shoppingcart && i18n_tool changed

pull_translations: ## pull translations from Transifex
tx pull -af --mode reviewed

push_translations: ## push source translation files (.po) from Transifex
tx push -s

dummy_translations: ## generate dummy translation (.po) files
cd shoppingcart && i18n_tool dummy

build_dummy_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files
test_migrations: ## check that Django migrations reflect all model changes
tox -e migrations

validate_translations: build_dummy_translations detect_changed_source_translations ## validate translations
format: ## apply standard code formatting
isort shoppingcart setup.py manage.py tests test_utils test_settings.py
black shoppingcart setup.py manage.py tests test_utils test_settings.py
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,25 @@ Primary authors were @johnbaldwin, @melvinsoft
Updated for standalone, Juniper/Py3 by @bryanlandia

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

## Testing

For some tests you need to run them from within a working Open edX environment.
Install in a Tutor devstack, then shell into the lms:

```sh
tutor dev exec lms -- bash
```

In the LMS shell, cd to the plugin directory:

```sh
cd /mnt/legacy-appsembler-api
```

Then you can run the unit tests (no unit tests yet):

```sh
pytest
python ./manage.py makemigrations shoppingcart --check --dry-run --verbosity 3
```
6 changes: 3 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

PWD = os.path.abspath(os.path.dirname(__file__))

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_settings')
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings")
sys.path.append(PWD)
try:
from django.core.management import execute_from_command_line
Expand All @@ -18,7 +18,7 @@
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django # pylint: disable=unused-import, wrong-import-position
import django # pylint: disable=unused-import
except ImportError as import_error:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
Expand Down
Loading