-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dou Du
committed
May 29, 2024
1 parent
4687a51
commit 373327c
Showing
5 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Voila test | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
voila: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '18.x' | ||
- name: Install Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
architecture: 'x64' | ||
- name: Install dependencies | ||
run: | ||
pip install --upgrade pip | ||
pip install --upgrade jupyterlab | ||
pip install --upgrade voila | ||
pip install --upgrade voila-osscar-template | ||
pip install -e . | ||
|
||
- name: Run the voila server | ||
run: | | ||
voila --template=osscar --enable_nbextensions=True example/ --port 8383 --no-browser & | ||
pip install --upgrade pytest | ||
pip install --upgrade selenium | ||
pip install --upgrade Pillow | ||
- uses: nanasess/setup-chromedriver@master | ||
- run: | | ||
export DISPLAY=:99 | ||
chromedriver --url-base=/wd/hub & | ||
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional | ||
python3 $GITHUB_WORKSPACE/test/test.py | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: quantum-screenshot | ||
path: './*.png' | ||
|
||
- name: Run the figures test | ||
run: | | ||
python3 $GITHUB_WORKSPACE/test/test_figures.py | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Selenium IDE | ||
import pytest | ||
import time | ||
import json | ||
import os | ||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.common.action_chains import ActionChains | ||
from selenium.webdriver.support import expected_conditions | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | ||
|
||
class test_widget(): | ||
def setup_method(self, method): | ||
options = Options() | ||
cwd = os.getcwd() | ||
options.add_experimental_option("prefs", {"download.default_directory": cwd}) | ||
self.driver = webdriver.Chrome(options=options) | ||
self.vars = {} | ||
|
||
def teardown_method(self, method): | ||
self.driver.quit() | ||
|
||
def download_widget_image(self): | ||
self.driver.get("http://localhost:8383/voila/render/example.ipynb") | ||
self.driver.set_window_size(1280, 720) | ||
time.sleep(3) | ||
self.driver.save_screenshot("widget-01.png") | ||
self.driver.execute_script("window.scrollTo(0, 1000)") | ||
time.sleep(3) | ||
self.driver.save_screenshot("widget-02.png") | ||
|
||
test = test_widget() | ||
test.setup_method('Chrome') | ||
test.download_widget_image() | ||
test.teardown_method('Chrome') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from PIL import Image, ImageChops, ImageStat | ||
|
||
image1 = Image.open('Figure 1.png') | ||
image2 = Image.open('test/widget-sample.png') | ||
|
||
diff = ImageChops.difference(image1, image2) | ||
stat = ImageStat.Stat(diff) | ||
|
||
if sum(stat.mean) == 0: | ||
print('images are the same') | ||
else: | ||
raise Exception("The result is NOT the same as expected. Please check matplotlib version.") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.