mirror of
https://github.com/umap-project/umap.git
synced 2025-05-06 06:21:49 +02:00
[docs] Add some testing information
This commit is contained in:
parent
87132314df
commit
fd71ded31b
4 changed files with 57 additions and 11 deletions
19
Makefile
19
Makefile
|
@ -1,5 +1,7 @@
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
JS_TEST_URL := http://localhost:8001/umap/static/umap/test/index.html
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: ## Install the dependencies
|
install: ## Install the dependencies
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
@ -73,10 +75,21 @@ vendors:
|
||||||
npm run vendors
|
npm run vendors
|
||||||
installjs:
|
installjs:
|
||||||
npm install
|
npm install
|
||||||
testjsfx:
|
|
||||||
firefox umap/static/umap/test/index.html
|
|
||||||
testjs: node_modules
|
testjs: node_modules
|
||||||
@./node_modules/mocha-phantomjs/bin/mocha-phantomjs --view 1024x768 umap/static/umap/test/index.html
|
@{ \
|
||||||
|
trap 'kill $$PID; exit' INT; \
|
||||||
|
python -m http.server 8001 & \
|
||||||
|
PID=$$!; \
|
||||||
|
sleep 1; \
|
||||||
|
echo "Opening $(JS_TEST_URL)"; \
|
||||||
|
if command -v python -m webbrowser > /dev/null 2>&1; then \
|
||||||
|
python -m webbrowser "$(JS_TEST_URL)"; \
|
||||||
|
else \
|
||||||
|
echo "Please open $(JS_TEST_URL) in your web browser"; \
|
||||||
|
fi; \
|
||||||
|
wait $$PID; \
|
||||||
|
}
|
||||||
tx_push:
|
tx_push:
|
||||||
tx push -s
|
tx push -s
|
||||||
tx_pull:
|
tx_pull:
|
||||||
|
|
|
@ -29,19 +29,52 @@ To be sure to install all the dev dependencies, and have everything working loca
|
||||||
make develop
|
make develop
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### JavaScript
|
||||||
|
|
||||||
|
For JavaScript, here is the tooling we use:
|
||||||
|
|
||||||
|
- Format your code with [Prettier](https://prettier.io/)
|
||||||
|
- Be sure to configure your editor to insert new lines at the end of files.
|
||||||
|
|
||||||
### Hack!
|
### Hack!
|
||||||
|
|
||||||
You can now do your changes in a specific branch, and when you're ready you can open a pull-request for us to review.
|
You can now do your changes in a specific branch, and when you're ready you can open a pull-request for us to review.
|
||||||
|
|
||||||
### Run tests
|
### Running tests
|
||||||
|
|
||||||
Multiple tests suites are in use in the project.
|
Multiple tests suites are in use in the project.
|
||||||
|
|
||||||
| Test suite | Location | Command |
|
|
||||||
| ---------- | -------- | ------- |
|
#### Python unit tests
|
||||||
| Python unit tests | `umap/tests/` | `pytest . --ignore umap/tests/integration` |
|
|
||||||
| Javascript unit tests | `umap/static/test` | `make testjs`|
|
```bash
|
||||||
| Integration tests | `umap/tests/integration` | `pytest umap/tests/integration` |
|
pytest . --ignore umap/tests/integration
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, the tests are run in parallel to reduce the time taken to run them. You can run them in serial mode by using the `-n1` option.
|
||||||
|
|
||||||
|
If you only want to run one test, you can add `-k specific-test-name` to the command line.
|
||||||
|
|
||||||
|
#### Integration tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pytest umap/tests/integration
|
||||||
|
```
|
||||||
|
|
||||||
|
The tests are using [Playwright](https://playwright.dev), which spawns a headless browser and runs the tests on it.
|
||||||
|
If the tests are failing, it might be useful to step trough the tests in the browser. This will let you go step by step with a debugger, so you can see what is happening on a real browser.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PWDEBUG=1 pytest --headed -n1 -k specific-test-name
|
||||||
|
```
|
||||||
|
|
||||||
|
#### JS tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make testjs
|
||||||
|
```
|
||||||
|
|
||||||
|
These tests are located in `umap/static/test`, and we are currently using a mocha test runner.
|
||||||
|
|
||||||
All the tests are run when you're creating a pull request, to avoid regressions.
|
All the tests are run when you're creating a pull request, to avoid regressions.
|
||||||
|
|
||||||
|
|
|
@ -168,4 +168,4 @@ pip install umap-project --upgrade
|
||||||
umap migrate
|
umap migrate
|
||||||
umap collectstatic
|
umap collectstatic
|
||||||
umap compress
|
umap compress
|
||||||
```
|
```
|
||||||
|
|
|
@ -16,7 +16,7 @@ from .managers import PublicManager
|
||||||
# Did not find a clean way to do this in Django
|
# Did not find a clean way to do this in Django
|
||||||
# - creating a Proxy model would mean replacing get_user_model by this proxy model
|
# - creating a Proxy model would mean replacing get_user_model by this proxy model
|
||||||
# in every template
|
# in every template
|
||||||
# - extending User model woulc mean a non trivial migration
|
# - extending User model would mean a non trivial migration
|
||||||
def display_name(self):
|
def display_name(self):
|
||||||
return settings.USER_DISPLAY_NAME.format(**self.__dict__)
|
return settings.USER_DISPLAY_NAME.format(**self.__dict__)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue