Skip to content

Commit 14ae110

Browse files
authored
Merge pull request #1276 from dannysepler/contributing
✏️ Fill in missing steps in CONTRIBUTING.md
2 parents 4e0502d + 830479b commit 14ae110

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
name: 🐍 Python Unit Tests & ☕ JS Unit Tests
6060
command: |
6161
. venv/bin/activate
62-
npm run test.unit
62+
npm run citest.unit
6363
6464
lint-unit-36:
6565
<<: *lint-unit
@@ -349,7 +349,7 @@ jobs:
349349
name: 🧪 Run Integration Tests
350350
command: |
351351
. venv/bin/activate
352-
npm run test.integration
352+
npm run citest.integration
353353
- store_artifacts:
354354
path: test-reports
355355
- store_test_results:

CONTRIBUTING.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ $ pip install -e .[testing,dev] # in some shells you need \ to escape []
1616
$ cd dash-renderer
1717
# build renderer bundles, this will build all bundles from source code
1818
# the only true source of npm version is defined in package.json
19+
$ npm install
1920
$ npm run build # or `renderer build`
2021
# install dash-renderer for development
2122
$ pip install -e .
2223
# build and install components used in tests
24+
$ cd .. # should be back in dash/ root directory
25+
$ npm install
2326
$ npm run setup-tests
2427
# you should see both dash and dash-renderer are pointed to local source repos
2528
$ pip list | grep dash
@@ -48,9 +51,7 @@ When a change in renderer code doesn't reflect in your browser as expected, this
4851

4952
Writing Python 2/3 compatible code might be a challenging task for contributors used to working on one particular version, especially new learners who start directly with Python 3.
5053

51-
From the #892, we started to adopt `python-future` instead of `six` as our tool to better achieve the goal where we can mainly write Python 3 code and make it back-compatible in Python 2.7 (last Python 2 version Dash supports before it gets deprecated).
52-
53-
Please refer to [this list of idioms](https://python-future.org/compatible_idioms.html "https://python-future.org/compatible_idioms.html") for more details on working with `python-future`.
54+
We use `python-future` as our tool to mainly write Python 3 code and make it back-compatible to Python 2.7 (the only Python 2 version Dash supports). Please refer to [this list of idioms](https://python-future.org/compatible_idioms.html "https://python-future.org/compatible_idioms.html") for more details on working with `python-future`.
5455

5556
## Git
5657

@@ -98,13 +99,15 @@ Emojis make the commit messages :cherry_blossom:. If you have no idea about what
9899

99100
### Coding Style
100101

101-
We use both `flake8` and `pylint` for basic linting check, please refer to the relevant steps in `.circleci/config.yml`.
102-
103-
Note that we also start using [`black`](https://black.readthedocs.io/en/stable/) as formatter during the test code migration.
102+
We use `flake8`, `pylint`, and [`black`](https://black.readthedocs.io/en/stable/) for linting. please refer to the relevant steps in `.circleci/config.yml`.
104103

105104
## Tests
106105

107-
We started migrating to [pytest](https://docs.pytest.org/en/latest/) from `unittest` as our test automation framework. You will see more testing enhancements in the near future.
106+
Our tests use Google Chrome via Selenium. You will need to install [ChromeDriver](http://chromedriver.chromium.org/getting-started) matching the version of Chrome installed on your system. Here are some helpful tips for [Mac](https://www.kenst.com/2015/03/installing-chromedriver-on-mac-osx/) and [Windows](http://jonathansoma.com/lede/foundations-2018/classes/selenium/selenium-windows-install/).
107+
108+
We use [pytest](https://docs.pytest.org/en/latest/) as our test automation framework, plus [jest](https://jestjs.io/) for a few renderer unit tests. You can `npm run test` to run them all, but this command simply runs `pytest` with no arguments, then `cd dash-renderer && npm run test` for the renderer unit tests.
109+
110+
Most of the time, however, you will want to just run a few relevant tests and let CI run the whole suite. `pytest` lets you specify a directory or file to run tests from (eg `pytest tests/unit`) or a part of the test case name using `-k` - for example `pytest -k cbcx004` will run a single test, or `pytest -k cbcx` will run that whole file. See the [testing tutorial](https://dash.plotly.com/testing) to learn about the test case ID convention we use.
108111

109112
### Unit Tests
110113

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
"private::test.py.deploy-standard": "npm run private::test.setup-standard && cd \\@plotly/dash-generator-test-component-standard && pip install -e .",
1717
"private::test.R.deploy-nested": "npm run private::test.setup-nested && cd \\@plotly/dash-generator-test-component-nested && sudo R CMD INSTALL .",
1818
"private::test.R.deploy-standard": "npm run private::test.setup-standard && cd \\@plotly/dash-generator-test-component-standard && sudo R CMD INSTALL .",
19-
"private::test.unit-dash": "PYTHONPATH=~/dash/tests/assets pytest tests/unit",
19+
"private::test.unit-dash": "pytest tests/unit",
2020
"private::test.unit-renderer": "cd dash-renderer && npm run test",
2121
"private::test.integration-dash": "TESTFILES=$(circleci tests glob \"tests/integration/**/test_*.py\" | circleci tests split --split-by=timings) && pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml ${TESTFILES}",
2222
"format": "run-s private::format.*",
2323
"initialize": "run-s private::initialize.*",
2424
"lint": "run-s private::lint.*",
2525
"setup-tests.py": "run-s private::test.py.deploy-*",
2626
"setup-tests.R": "run-s private::test.R.deploy-*",
27-
"test.integration": "run-s setup-tests.py private::test.integration-*",
28-
"test.unit": "run-s private::test.unit-**"
27+
"citest.integration": "run-s setup-tests.py private::test.integration-*",
28+
"citest.unit": "run-s private::test.unit-**",
29+
"test": "pytest && cd dash-renderer && npm run test"
2930
},
3031
"devDependencies": {
3132
"husky": "4.2.3"

tests/unit/test_app_runners.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23
import requests
34
import pytest
@@ -25,7 +26,14 @@ def test_threaded_server_smoke(dash_thread_server):
2526
sys.version_info < (3,), reason="requires python3 for process testing"
2627
)
2728
def test_process_server_smoke(dash_process_server):
28-
dash_process_server("simple_app")
29-
r = requests.get(dash_process_server.url)
30-
assert r.status_code == 200, "the server is reachable"
31-
assert 'id="react-entry-point"' in r.text, "the entrypoint is present"
29+
cwd = os.getcwd()
30+
this_dir = os.path.dirname(__file__)
31+
assets_dir = os.path.abspath(os.path.join(this_dir, "..", "assets"))
32+
try:
33+
os.chdir(assets_dir)
34+
dash_process_server("simple_app")
35+
r = requests.get(dash_process_server.url)
36+
assert r.status_code == 200, "the server is reachable"
37+
assert 'id="react-entry-point"' in r.text, "the entrypoint is present"
38+
finally:
39+
os.chdir(cwd)

0 commit comments

Comments
 (0)