#!/bin/bash
set -e

pkg=pyensembl
if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

cp -a tests scripts pyproject.toml "$AUTOPKGTEST_TMP/"

cd $AUTOPKGTEST_TMP

export HOME="$AUTOPKGTEST_TMP"
# Local HTTP fixtures must bypass any proxy configured in the testbed.
export no_proxy=localhost,127.0.0.1,::1

# common.py and data.py are missing from the source tarball in Pypi, but these
# files are present in the Github source code. These files are required to run
# the following tests:
rm tests/test_download_cache.py
rm tests/test_ensembl_gtf.py
rm tests/test_gene_ids.py
rm tests/test_gene_names.py
rm tests/test_gene_objects.py
rm tests/test_id_length.py
rm tests/test_missing_genome_sources.py
rm tests/test_mouse.py
rm tests/test_search.py
rm tests/test_sequence_data.py
rm tests/test_serialization.py
rm tests/test_transcript_ids.py
rm tests/test_transcript_objects.py
rm tests/test_ucsc_gtf.py

# pyensembl is missing a dependency needed to import test data. The test data
# could be added to debian/tests/data or in a multi-source tarball depending
# on the size of data being added. The following tests are affected:
rm tests/test_contigs.py
rm tests/test_exon_id.py
rm tests/test_exon_object.py
rm tests/test_string_representation.py
rm tests/test_timings.py
rm tests/test_transcript_sequences.py
rm tests/test_transcript_support_level.py

# The release guard reads pyensembl/version.py from a source checkout.
# Keep these checks in the build tests.
rm tests/test_release_version_guard.py

# Match the PyArrow extension modules required through gtfparse.
python3 --version
# This integration case needs separately installed Ensembl 93 data.
python3 -m pytest tests -k 'not test_issue_445_examples_on_ensembl_93'
