Dockerize tests

This commit is contained in:
Aitor Magán 2016-03-02 15:43:23 +01:00
parent 57e486c5e8
commit c47949155e
4 changed files with 20 additions and 16 deletions

View File

@ -6,14 +6,13 @@ export PATH=$PATH:/usr/local/bin
export PIP_DOWNLOAD_CACHE=~/.pip_cache
WD=`pwd`
DB_HOST_IP=${DB_HOST_IP:=127.0.0.1}
POSTGRES_PORT=${POSTGRES_PORT:=5432}
CACHE_DIR=~/.cache
echo "Downloading CKAN..."
git clone https://github.com/ckan/ckan
cd ckan
git checkout release-v2.3
git checkout release-v2.5.2
cd $WD
@ -32,7 +31,7 @@ then
if [ ! -d "$CACHE_DIR/$SOLAR_UNZIP_FOLDER" ]
then
# Download the solar installation file if it does not exist
wget --quiet --timestamping --directory-prefix=$CACHE_DIR http://apache.rediris.es/lucene/solr/4.8.1/$FILE
wget --no-verbose --timestamping --directory-prefix=$CACHE_DIR https://archive.apache.org/dist/lucene/solr/4.8.1/$FILE
# Unzip the folder
tar -xf "$CACHE_DIR/$FILE" --directory "$CACHE_DIR"
@ -63,8 +62,8 @@ pip install --upgrade pip
echo "Installing CKAN dependencies..."
cd ckan
python setup.py develop
pip install -r requirements.txt --allow-all-external
pip install -r dev-requirements.txt --allow-all-external
pip install -r requirements.txt
pip install -r dev-requirements.txt
cd ..
@ -83,15 +82,15 @@ sudo -u postgres psql -c 'CREATE DATABASE datastore_test WITH OWNER ckan_default
echo "Modifying the configuration to setup properly the Postgres port..."
mkdir -p data/storage
echo "
sqlalchemy.url = postgresql://ckan_default:pass@localhost:$POSTGRES_PORT/ckan_test
ckan.datastore.write_url = postgresql://ckan_default:pass@localhost:$POSTGRES_PORT/datastore_test
ckan.datastore.read_url = postgresql://datastore_default:pass@localhost:$POSTGRES_PORT/datastore_test
sqlalchemy.url = postgresql://ckan_default:pass@$DB_HOST_IP:$POSTGRES_PORT/ckan_test
ckan.datastore.write_url = postgresql://ckan_default:pass@$DB_HOST_IP:$POSTGRES_PORT/datastore_test
ckan.datastore.read_url = postgresql://datastore_default:pass@$DB_HOST_IP:$POSTGRES_PORT/datastore_test
ckan.storage_path=data/storage" >> test.ini
echo "Initializing the database..."
sed -i "s/\(postgresql:\/\/.\+@localhost\)/\1:$POSTGRES_PORT/g" ckan/test-core.ini
sed -i "s/\(postgresql:\/\/.\+\)@localhost\(:[0-9]\+\)\?/\1@$DB_HOST_IP:$POSTGRES_PORT/g" ckan/test-core.ini
cd ckan
paster db init -c test-core.ini
cd ..

View File

@ -66,10 +66,15 @@ class TestSelenium(unittest.TestCase):
def setUp(self):
self.clearBBDD()
self.driver = webdriver.Firefox()
if 'WEB_DRIVER_URL' in os.environ and 'CKAN_SERVER_URL' in os.environ:
self.driver = webdriver.Remote(os.environ['WEB_DRIVER_URL'], webdriver.DesiredCapabilities.FIREFOX.copy())
self.base_url = os.environ['CKAN_SERVER_URL']
else:
self.driver = webdriver.Firefox()
self.base_url = 'http://127.0.0.1:5000/'
self.driver.implicitly_wait(5)
self.driver.set_window_size(1024, 768)
self.base_url = 'http://127.0.0.1:5000/'
def tearDown(self):
self.clearBBDD()
@ -177,7 +182,7 @@ class TestSelenium(unittest.TestCase):
driver.find_element_by_id('field-description').clear()
driver.find_element_by_id('field-description').send_keys(resource_description)
driver.find_element_by_id('s2id_autogen1').clear()
driver.find_element_by_id('s2id_autogen1').send_keys(resource_format)
driver.find_element_by_id('s2id_autogen1').send_keys(resource_format + '\n')
driver.find_element_by_css_selector('button.btn.btn-primary').click()
def modify_ds(self, url, name, description, tags, private, searchable, allowed_users, acquire_url):

View File

@ -48,7 +48,7 @@ setup(
],
tests_require=[
'nose_parameterized==0.3.3',
'selenium==2.46.0'
'selenium==2.52.0'
],
test_suite='nosetests',
entry_points='''
@ -56,4 +56,4 @@ setup(
# Add plugins here, e.g.
privatedatasets=ckanext.privatedatasets.plugin:PrivateDatasets
''',
)
)

View File

@ -6,7 +6,7 @@ port = 5000
[app:main]
use = config:./ckan/test-core.ini
ckan.legacy_templates = No
ckan.legacy_templates = no
ckan.plugins = privatedatasets
ckan.privatedatasets.parser = ckanext.privatedatasets.parsers.fiware:FiWareNotificationParser
ckan.privatedatasets.show_acquire_url_on_create = True