mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-01 15:37:32 +08:00
Setup pytest python3 API testing
This commit is contained in:
@@ -19,6 +19,9 @@ selenium = "*"
|
||||
testfixtures = "*"
|
||||
watchdog = "*"
|
||||
pygithub3 = {version = "*", markers = "python_version < '3'"}
|
||||
pytest = "*"
|
||||
pytest-html = "*"
|
||||
pytest-pythonpath = "*"
|
||||
Sphinx = "<1.7" # Docs do not build with sphinx 1.7 for some reason, can't find issue.
|
||||
sphinx_rtd_theme = "*"
|
||||
lxml = "!=4.2.2"
|
||||
|
||||
@@ -21,6 +21,9 @@ pathtools==0.1.2
|
||||
pbr==4.1.0
|
||||
pygithub3==0.5.1; python_version < '3'
|
||||
pygments==2.2.0
|
||||
pytest==3.7.0
|
||||
pytest-html==1.19.0
|
||||
pytest-pythonpath==0.7.2
|
||||
pytz==2018.5
|
||||
pyyaml==3.12
|
||||
recommonmark==0.4.0
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[pytest]
|
||||
log_cli=true
|
||||
log_level=DEBUG
|
||||
python_paths=lib
|
||||
+27
-2
@@ -11,6 +11,7 @@ cat <<EOF
|
||||
'${0##*/} -sid ccc' for testing one section with sid 'ccc' ('ccc' is the string after 'section::')
|
||||
'${0##*/} -list' for listing all the tool ids
|
||||
'${0##*/} -api (test_path)' for running all the test scripts in the ./test/api directory
|
||||
'${0##*/} -api_py3 (test_path)' for running all the test scripts in the ./test/api directory using python 3
|
||||
'${0##*/} -toolshed (test_path)' for running all the test scripts in the ./test/shed_functional/functional directory
|
||||
'${0##*/} -installed' for running tests of Tool Shed installed tools
|
||||
'${0##*/} -framework' for running through example tool tests testing framework features in test/functional/tools"
|
||||
@@ -275,6 +276,10 @@ then
|
||||
DOCKER_EXTRA_ARGS=${DOCKER_ARGS:-""}
|
||||
DOCKER_RUN_EXTRA_ARGS=${DOCKER_RUN_EXTRA_ARGS:-""}
|
||||
DOCKER_IMAGE=${DOCKER_IMAGE:-${DOCKER_DEFAULT_IMAGE}}
|
||||
if [ "$1" = "--python3" ]; then
|
||||
DOCKER_RUN_EXTRA_ARGS="-e GALAXY_VIRTUAL_ENV=/galaxy_venv3 $DOCKER_RUN_EXTRA_ARGS"
|
||||
shift 1
|
||||
fi
|
||||
if [ "$1" = "--db" ]; then
|
||||
db_type=$2
|
||||
shift 2
|
||||
@@ -350,6 +355,18 @@ do
|
||||
shift 1
|
||||
fi
|
||||
;;
|
||||
-api_py3|--api_py3)
|
||||
with_framework_test_tools_arg="-with_framework_test_tools"
|
||||
test_script="pytest"
|
||||
report_file="./run_api_tests_python_3.html"
|
||||
if [ $# -gt 1 ]; then
|
||||
api_script=$2
|
||||
shift 2
|
||||
else
|
||||
api_script="./test/api"
|
||||
shift 1
|
||||
fi
|
||||
;;
|
||||
-selenium|--selenium)
|
||||
with_framework_test_tools_arg="-with_framework_test_tools"
|
||||
test_script="./scripts/functional_tests.py"
|
||||
@@ -595,7 +612,11 @@ else
|
||||
fi
|
||||
|
||||
if [ -n "$xunit_report_file" ]; then
|
||||
xunit_args="--with-xunit --xunit-file $xunit_report_file"
|
||||
if [ "$test_script" = 'pytest' ]; then
|
||||
xunit_args="--junit-xml $xunit_report_file"
|
||||
else
|
||||
xunit_args="--with-xunit --xunit-file $xunit_report_file"
|
||||
fi
|
||||
else
|
||||
xunit_args=""
|
||||
fi
|
||||
@@ -608,7 +629,11 @@ if [ -n "$with_framework_test_tools_arg" ]; then
|
||||
GALAXY_TEST_TOOL_CONF="config/tool_conf.xml.sample,test/functional/tools/samples_tool_conf.xml"
|
||||
export GALAXY_TEST_TOOL_CONF
|
||||
fi
|
||||
python $test_script $coverage_arg -v --with-nosehtml --html-report-file $report_file $xunit_args $structured_data_args $extra_args "$@"
|
||||
if [ "$test_script" = 'pytest' ]; then
|
||||
python -m "$test_script" -v --html "$report_file" $xunit_args $extra_args "$@"
|
||||
else
|
||||
python $test_script $coverage_arg -v --with-nosehtml --html-report-file $report_file $xunit_args $structured_data_args $extra_args "$@"
|
||||
fi
|
||||
exit_status=$?
|
||||
echo "Testing complete. HTML report is in \"$report_file\"." 1>&2
|
||||
exit ${exit_status}
|
||||
|
||||
@@ -18,7 +18,10 @@ def link_up_static(f):
|
||||
elif not os.path.exists(dest_parent):
|
||||
# Create parent dir structure to symlink directly to static.
|
||||
os.makedirs(dest_parent)
|
||||
os.symlink(src, dest)
|
||||
try:
|
||||
os.symlink(src, dest)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -10,7 +10,9 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
||||
MYSQL_MAJOR=5.7 \
|
||||
POSTGRES_MAJOR=9.5 \
|
||||
GALAXY_ROOT=/galaxy \
|
||||
GALAXY_VIRTUAL_ENV=/galaxy_venv
|
||||
GALAXY_VIRTUAL_ENV=/galaxy_venv \
|
||||
GALAXY_VIRTUAL_ENV_2=/galaxy_venv \
|
||||
GALAXY_VIRTUAL_ENV_3=/galaxy_venv3
|
||||
|
||||
# Pre-install a bunch of packages to speed up ansible steps.
|
||||
RUN apt-get update -y && apt-get install -y software-properties-common apt-transport-https curl && \
|
||||
@@ -79,11 +81,15 @@ RUN mkdir /etc/galaxy && cd /tmp/ansible && mkdir roles && \
|
||||
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
RUN cd $GALAXY_ROOT && \
|
||||
./scripts/common_startup.sh || { echo "common_startup.sh failed"; exit 1; } && \
|
||||
dev_requirements=./lib/galaxy/dependencies/dev-requirements.txt && \
|
||||
[ -f $dev_requirements ] && $GALAXY_VIRTUAL_ENV/bin/pip install -r $dev_requirements
|
||||
for VENV in $GALAXY_VIRTUAL_ENV_2 $GALAXY_VIRTUAL_ENV_3; do \
|
||||
export GALAXY_VIRTUAL_ENV=$VENV && \
|
||||
./scripts/common_startup.sh || { echo "common_startup.sh failed"; exit 1; } && \
|
||||
dev_requirements=./lib/galaxy/dependencies/dev-requirements.txt && \
|
||||
[ -f $dev_requirements ] && $VENV/bin/pip install -r $dev_requirements; done
|
||||
|
||||
RUN . $GALAXY_VIRTUAL_ENV/bin/activate && \
|
||||
RUN for VENV in $GALAXY_VIRTUAL_ENV_2 $GALAXY_VIRTUAL_ENV_3; do \
|
||||
export GALAXY_VIRTUAL_ENV=$VENV && \
|
||||
. $GALAXY_VIRTUAL_ENV/bin/activate && \
|
||||
pip install psycopg2 && \
|
||||
pip install mysql && \
|
||||
cd $GALAXY_ROOT && \
|
||||
@@ -101,7 +107,7 @@ RUN . $GALAXY_VIRTUAL_ENV/bin/activate && \
|
||||
echo "Prepopulating toolshed sqlite database" && \
|
||||
TOOL_SHED_CONFIG_DATABASE_CONNECTION="sqlite:////opt/galaxy/toolshed.sqlite" bash create_db.sh tool_shed && \
|
||||
echo "Prepopulating toolshed mysql database" && \
|
||||
TOOL_SHED_CONFIG_DATABASE_CONNECTION="mysql://galaxy:galaxy@localhost/toolshed?unix_socket=/var/run/mysqld/mysqld.sock" bash create_db.sh tool_shed
|
||||
TOOL_SHED_CONFIG_DATABASE_CONNECTION="mysql://galaxy:galaxy@localhost/toolshed?unix_socket=/var/run/mysqld/mysqld.sock" bash create_db.sh tool_shed; done
|
||||
|
||||
# bcftools for Galaxy.
|
||||
RUN mkdir -p /tmp/install && \
|
||||
|
||||
@@ -18,7 +18,7 @@ echo "Creating galaxy user with uid $GALAXY_TEST_UID - it may already exist and
|
||||
useradd -u $GALAXY_TEST_UID -r -g galaxy -d /home/galaxy -c "Galaxy User" galaxy -s /bin/bash | true
|
||||
echo "Setting galaxy user password - the operation may fail."
|
||||
echo "galaxy:galaxy" | chpasswd | true
|
||||
chown -R "$GALAXY_TEST_UID:$GALAXY_TEST_UID" /galaxy_venv
|
||||
chown -R "$GALAXY_TEST_UID:$GALAXY_TEST_UID" "${GALAXY_VIRTUAL_ENV:-/galaxy_venv}"
|
||||
|
||||
: ${GALAXY_TEST_DATABASE_TYPE:-"postgres"}
|
||||
if [ "$GALAXY_TEST_DATABASE_TYPE" = "postgres" ];
|
||||
|
||||
Reference in New Issue
Block a user