Skip to content

Commit ac0fdf8

Browse files
committed
Add some test for the examples and run them in the GitHub Actions
1 parent 104e0c1 commit ac0fdf8

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ jobs:
2626
- name: Run the tests
2727
run: |
2828
pytest
29+
- name: Install the Python dependencies for the examples
30+
run: |
31+
cd examples/simple && pip install -e '3.5
32+
- name: Run the tests for the examples
33+
run: |
34+
pytest examples/simple/tests/*

examples/simple/pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
# Disable any upper exclusion.
3+
norecursedirs =

examples/simple/setup.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ def add_data_files(path):
3333
'jupyter_server',
3434
'jinja2',
3535
],
36-
tests_requires = [
37-
'pytest',
38-
'pytest-cov',
39-
'pylint',
40-
],
4136
include_package_data=True,
4237
data_files = get_data_files(),
4338
entry_points = {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def server_config(template_dir):
6+
return {
7+
"ServerApp": {
8+
"jpserver_extensions": {
9+
"simple_ext1": True
10+
}
11+
},
12+
}
13+
14+
15+
async def test_handler_default(fetch):
16+
r = await fetch(
17+
'simple_ext1/default',
18+
method='GET'
19+
)
20+
assert r.code == 200
21+
print(r.body.decode())
22+
assert r.body.decode() == "<h1>Hello Simple 1 - I am the default...</h1>Config in simple_ext1 Default Handler: {'configA': '', 'configB': '', 'configC': ''}"
23+
24+
25+
async def test_handler_template(fetch):
26+
r = await fetch(
27+
'simple_ext1/template1/test',
28+
method='GET'
29+
)
30+
assert r.code == 200

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
# Exclude the example tests.
3+
norecursedirs = examples/*

0 commit comments

Comments
 (0)