diff --git a/.travis.yml b/.travis.yml index 865f048..b45a4c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ cache: before_install: - echo "Installing C++ and Python" - sudo apt-get update && sudo apt-get install -y --no-install-recommends --no-install-suggests g++ python-dev python3-dev python3-pip maven libnuma-dev libc-dev python3-venv openmpi-bin libopenmpi-dev flex bison libomp-dev - - sudo apt-get install gsl-bin libgsl0-dev libboost-all-dev + - sudo apt-get install gsl-bin libgsl0-dev libboost-all-dev imagemagick-6.q16 inkscape - cp /var/cache/apt/archives/*.deb $HOME/.cache/apt/ - export BOOST_LIBDIR=/usr/lib/x86_64-linux-gnu/ @@ -23,5 +23,6 @@ jobs: include: - stage: "Build Stages" script: - - make + - make all + - cd bin && ./test.sh name: "Build Project" \ No newline at end of file diff --git a/bin/npshape-frontend.ipynb b/bin/npshape-frontend.ipynb index af3dae6..9191af2 100755 --- a/bin/npshape-frontend.ipynb +++ b/bin/npshape-frontend.ipynb @@ -52,7 +52,7 @@ "from hublib.ui import Submit\n", "from hublib.ui import RunCommand\n", "import hublib.use\n", - "%use boost-1.62.0-mpich2-1.3-gnu-4.7.2\n", + "#%use boost-1.62.0-mpich2-1.3-gnu-4.7.2\n", "#%use lammps-31Mar17\n", "import numpy as np\n", "import re\n", @@ -2021,7 +2021,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.5" + "version": "3.8.5" }, "tool": false, "widgets": { diff --git a/bin/test.sh b/bin/test.sh new file mode 100755 index 0000000..6edc857 --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +python3 -m venv ENV + +source ENV/bin/activate + +pip install hublib +pip install jupyterlab +pip install testbook +pip install widgetsnbextension +pip install svgwrite +pip install pypng +pip install pytest +pip install matplotlib +pip install ipywidgets +jupyter nbextension enable --py widgetsnbextension + +export ENVIRON_CONFIG_DIRS="," +pytest test || exit 1 + diff --git a/bin/test/npshape_test.py b/bin/test/npshape_test.py new file mode 100644 index 0000000..ce3bccb --- /dev/null +++ b/bin/test/npshape_test.py @@ -0,0 +1,34 @@ +import testbook +import os +import svgwrite +import png + +@testbook.testbook('npshape-frontend.ipynb', execute=True) +def test_combine_4_PNGs(tb): + f = open('test/resources/test.png', 'wb') # binary mode is important + w = png.Writer(256, 1, greyscale=True) + w.write(f, [range(256)]) + f.close() + if not os.path.exists('snapshot_png'): + os.mkdir("snapshot_png") + + func = tb.ref("combine_4_PNGs") + func("test/resources/test.png", "test/resources/test.png", "test/resources/test.png", "test/resources/test.png", "test/resources/output.png") + assert os.path.exists("test/resources/output.png") == 1 + os.remove("test/resources/output.png") + +@testbook.testbook('npshape-frontend.ipynb', execute=True) +def test_convert_SVG_PNG(tb): + func = tb.ref("convert_SVG_PNG") + + dwg = svgwrite.Drawing('test/resources/test.svg', profile='tiny', size=(270, 270)) + dwg.add(dwg.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%'))) + dwg.add(dwg.text('Test', insert=(0, 0.2), fill='red')) + dwg.save() + if not os.path.exists('snapshot_png'): + os.mkdir("snapshot_png") + + func("test/resources/test.svg", "test/resources/output.png") + assert os.path.exists("test/resources/output.png") == 1 + os.remove("test/resources/output.png") + diff --git a/bin/test/resources/test.png b/bin/test/resources/test.png new file mode 100644 index 0000000..9d57f7f Binary files /dev/null and b/bin/test/resources/test.png differ diff --git a/bin/test/resources/test.svg b/bin/test/resources/test.svg new file mode 100644 index 0000000..4b01153 --- /dev/null +++ b/bin/test/resources/test.svg @@ -0,0 +1,2 @@ + +Test \ No newline at end of file