Skip to content

Commit

Permalink
Quit driver when done. Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
bhilbert4 committed Sep 21, 2023
1 parent 477072f commit 03da9a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion jwql/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
from pathlib import Path
import pytest

from jwql.utils.utils import copy_files, get_config, filename_parser, filesystem_path, _validate_config
from bokeh.models import LinearColorMapper
from bokeh.plotting import figure
import numpy as np

from jwql.utils.utils import copy_files, get_config, filename_parser, filesystem_path, save_png, _validate_config


# Determine if tests are being run on Github Actions
Expand Down Expand Up @@ -479,6 +483,19 @@ def test_filesystem_path():
assert check == location


def test_save_png():
"""Test that we can create a png file"""
plot = figure(title='test',tools='')
image = np.zeros((200,200))
image[100:105, 100:105] = 1
ny, nx = image.shape
mapper = LinearColorMapper(palette='Viridis256', low=0 ,high=1.1)
imgplot = plot.image(image=[image], x=0, y=0, dw=nx, dh=ny, color_mapper=mapper, level="image")
#save_png(plot, filename='test.png')
from bokeh.io import export_png
export_png(plot, filename='test.png')


@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to central storage.')
def test_validate_config():
"""Test that the config validator works."""
Expand Down
1 change: 1 addition & 0 deletions jwql/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def save_png(fig, filename=''):
options.add_argument('-headless')
driver = webdriver.Firefox(options=options)
export_png(fig, filename=filename, webdriver=driver)
driver.quit()


def grouper(iterable, chunksize):
Expand Down

0 comments on commit 03da9a8

Please sign in to comment.