#!/bin/sh

#
# Just start a ds9 instance, load a file, try to access this file, and then
# quit.
#
cp test.fits "${AUTOPKGTEST_TMP}"
cd "${AUTOPKGTEST_TMP}"

xvfb-run --server-args="-screen 0 1024x768x24" python3 <<EOF
import time
import pyds9
d = pyds9.DS9('test')
time.sleep(1)
print(pyds9.ds9_targets())
d.set('file test.fits')
hdul = d.get_pyfits()
hdul.info()
hdul.writeto('test1.fits')
d.set('quit')
EOF

res=$?


ls -l

if [ $res = 0 ] ; then
    echo "All OK"
    exit 0
else
    echo "Failure"
    exit $res
fi
