Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #182

Merged
merged 6 commits into from
Sep 6, 2023
Merged

Tests #182

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
65 changes: 51 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: |
pip install jupyterlab
pip install "jupyterlab>=4.0.0,<5"
pip install -e .
jlpm

- name: Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage=manual

- name: Help message if pre-commit fail
if: ${{ failure() }}
run: |
Expand All @@ -39,6 +46,7 @@ jobs:
echo " pre-commit run"
echo "or after-the-fact on already committed files with"
echo " pre-commit run --all-files --hook-stage=manual"

- name: Lint frontend
run: |
jlpm run lint:check
Expand All @@ -49,15 +57,21 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: |
pip install jupyterlab
pip install "jupyterlab>=4.0.0,<5"
pip install -e .
jlpm

- name: Run Tests
run: |
set -eux
Expand All @@ -72,34 +86,47 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.11"]
include:
- os: ubuntu-latest
python-version: "pypy-3.8"
# PyPy is not supported because we use the file_id_manager. See:
# https://github.com/jupyter-server/jupyter_server_fileid/issues/44
#include:
# - os: ubuntu-latest
# python-version: "pypy-3.8"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install the Python dependencies
run: |
python -m pip install "jupyterlab>=4.0.0,<5"
pip install -e ".[test]" codecov
python -m pip install jupyterlab

- name: List installed packages
run: |
pip freeze
pip check

- name: Run the tests with Coverage
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(runner.os, 'Windows') }}
run: |
python -m pytest -vv --cov jupyter_collaboration --cov-branch --cov-report term-missing:skip-covered
- name: Run the tests on pypy and Windows
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(runner.os, 'Windows') }}
run: |
python -W ignore::ImportWarning -m pytest -vv
- name: Coverage
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(runner.os, 'Windows') }}

#- name: Run the tests on pypy
# if: ${{ startsWith(matrix.python-version, 'pypy') }}
# run: |
# PyPy is not supported because we use the file_id_manager. See:
# https://github.com/jupyter-server/jupyter_server_fileid/issues/44
# python -W ignore::ImportWarning -m pytest -vv

- name: Run the tests on Windows
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
codecov
python -W ignore::ImportWarning -m pytest -vv --cov jupyter_collaboration --cov-branch --cov-report term-missing:skip-covered

- uses: jupyterlab/maintainer-tools/.github/actions/upload-coverage@v1

- name: Build the extension
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
shell: bash
Expand All @@ -118,12 +145,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: "3.11"

- name: Install minimum versions
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1

- name: Run the unit tests
run: |
pytest -vv -W default || pytest -vv -W default --lf
Expand All @@ -136,15 +166,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install the Python dependencies
run: |
pip install --pre -e ".[test]"

- name: List installed packages
run: |
pip freeze
pip check

- name: Run the tests
run: |
pytest -vv -W default || pytest -vv --lf
Expand All @@ -166,8 +200,10 @@ jobs:
timeout-minutes: 15
steps:
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Download sdist
uses: actions/download-artifact@v3

- name: Install From SDist
shell: bash
run: |
Expand All @@ -177,9 +213,10 @@ jobs:
mkdir test
tar --strip-components=1 -zxvf *.tar.gz -C ./test
cd test
python -m pip install "jupyterlab>=4.0.0,<5"
python -m pip install ".[test]"
python -m pip install jupyterlab
echo "::endgroup::"

- name: Run Test
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions jupyter_collaboration/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def get(self, *args, **kwargs):
"""
Overrides default behavior to check whether the client is authenticated or not.
"""
if self.get_current_user() is None:
if self.current_user is None:
self.log.warning("Couldn't authenticate WebSocket connection")
raise web.HTTPError(403)
return await super().get(*args, **kwargs)
Expand Down Expand Up @@ -258,7 +258,7 @@ async def on_message(self, message):
if message_type == MessageType.CHAT:
msg = message[2:].decode("utf-8")

user = self.get_current_user()
user = self.current_user
data = json.dumps(
{"sender": user.username, "timestamp": time.time(), "content": json.loads(msg)}
).encode("utf8")
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ dev = [
test = [
"coverage",
"jupyter_server[test]>=2.0.0",
"jupyter_server_fileid[test]",
"pytest>=7.0",
"pytest-cov",
"pytest-asyncio"
"pytest-asyncio",
"websockets"
]
docs = [
"jupyterlab>=4.0.0",
Expand Down
Loading
Loading