Skip to content

Commit

Permalink
Merge pull request #129 from manics/netcat-openbsd
Browse files Browse the repository at this point in the history
Install netcat-openbsd in tests and update screenshots for ubuntu 24.04
  • Loading branch information
manics committed Sep 15, 2024
2 parents 30e67eb + 646cedf commit cf07279
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
echo "::group::Install netcat, a test dependency"
docker exec --user root $container_id bash -c '
apt update
apt install -y netcat
apt install -y netcat-openbsd
'
echo "::endgroup::"
Expand Down Expand Up @@ -95,6 +95,7 @@ jobs:
export CONTAINER_ID=$container_id
export JUPYTER_HOST=http://localhost:8888
export JUPYTER_TOKEN=secret
export VNCSERVER=${{ matrix.vncserver }}
python -mpytest -vs
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This is based on https://github.com/ryanlovett/nbnovnc.

When this extension is launched it will run a Linux desktop on the Jupyter single-user server, and proxy it to your browser using VNC via Jupyter.

![Screenshot of jupyter-remote-desktop-proxy XFCE desktop](https://raw.githubusercontent.com/jupyterhub/jupyter-remote-desktop-proxy/main/tests/reference/desktop.png)

## VNC Server

This extension requires a [VNC Server](https://en.wikipedia.org/wiki/Virtual_Network_Computing)
Expand Down
Binary file added tests/reference/desktop-turbovnc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/reference/desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
CONTAINER_ID = getenv("CONTAINER_ID", "test")
JUPYTER_HOST = getenv("JUPYTER_HOST", "http://localhost:8888")
JUPYTER_TOKEN = getenv("JUPYTER_TOKEN", "secret")
VNCSERVER = getenv("VNCSERVER")


def compare_screenshot(test_image, threshold=2):
def compare_screenshot(test_image):
# Compare images by calculating the mean absolute difference
# Images must be the same size
# threshold: Average difference per pixel, this depends on the image type
# e.g. for 24 bit images (8 bit RGB pixels) threshold=1 means a maximum
# difference of 1 bit per pixel per channel
reference = Image.open(HERE / "reference" / "desktop.png")
threshold = 2
if VNCSERVER == "turbovnc":
reference = Image.open(HERE / "reference" / "desktop-turbovnc.png")
# The TurboVNC screenshot varies a lot more than TigerVNC
threshold = 6
test = Image.open(test_image)

# Absolute difference
Expand Down Expand Up @@ -53,7 +59,7 @@ def test_desktop(browser):
page1.wait_for_timeout(5000)
# Use a non temporary folder so we can check it manually if necessary
screenshot = Path("screenshots") / "desktop.png"
page1.locator("canvas").screenshot(path=screenshot)
page1.locator("body").screenshot(path=screenshot)

# Open clipboard, enter random text, close clipboard
clipboard_text = str(uuid4())
Expand Down

0 comments on commit cf07279

Please sign in to comment.