[go: nahoru, domu]

Skip to content

Commit

Permalink
Add travis and a basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
joetsoi committed Apr 20, 2015
1 parent b48dbc3 commit 7020cff
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: python
python:
- "2.7"
env:
- CKANVERSION=master
- CKANVERSION=2.2
- CKANVERSION=2.3
install:
- bash bin/travis-build.bash
script: sh bin/travis-run.sh
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/okfn/ckanext-issues.svg?branch=master)](https://travis-ci.org/okfn/ckanext-issues)
[![Coverage Status](https://coveralls.io/repos/okfn/ckanext-issues/badge.svg)](https://coveralls.io/r/okfn/ckanext-issues
ckanext-pages
=============

Expand Down
44 changes: 44 additions & 0 deletions bin/travis-build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

echo "This is travis-build.bash..."

echo "Installing the packages that CKAN requires..."
sudo apt-get update -qq
sudo apt-get install postgresql-$PGVERSION solr-jetty libcommons-fileupload-java:amd64=1.2.2-1

echo "Installing CKAN and its Python dependencies..."
git clone https://github.com/ckan/ckan
cd ckan
if [ $CKANVERSION == '2.3' ]
then
git checkout release-v2.3
elif [ $CKANVERSION == '2.2' ]
then
git checkout release-v2.2.3
fi
python setup.py develop
cp ./ckan/public/base/css/main.css ./ckan/public/base/css/main.debug.css
pip install -r requirements.txt --allow-all-external
pip install -r dev-requirements.txt --allow-all-external
cd -

echo "Creating the PostgreSQL user and database..."
sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';"
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckan_default;'
sudo -u postgres psql -c 'CREATE DATABASE datastore_test WITH OWNER ckan_default;'

#echo "Initialising the database..."
#cd ckan
#paster db init -c test-core.ini
#cd -

echo "Installing ckanext-pages and its requirements..."
python setup.py develop
pip install -r dev-requirements.txt

echo "Moving test.ini into a subdir..."
mkdir subdir
mv test.ini subdir

echo "travis-build.bash is done."
6 changes: 6 additions & 0 deletions bin/travis-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
sudo service jetty restart
nosetests --ckan --nologcapture --with-pylons=subdir/test.ini --reset-db --with-coverage --cover-package=ckanext.pages --cover-inclusive --cover-erase --cover-tests
25 changes: 25 additions & 0 deletions ckanext/pages/tests/test_logic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from ckan.plugins import toolkit
from ckan.new_tests import factories, helpers


class TestUpdate(helpers.FunctionalTestBase):
def setup(self):
super(TestUpdate, self).setup()
self.user = factories.Sysadmin()
self.app = self._get_test_app()

def teardown(self):
helpers.reset_db()

def test_create_page(self):
env = {'REMOTE_USER': self.user['name'].encode('ascii')}
response = self.app.post(
url=toolkit.url_for('pages_edit', page='/test_page'),
params={
'title': 'Page Title',
'name': 'page_name',
},
extra_environ=env,
)
response = response.follow(extra_environ=env)
assert '<h1 class="page-heading">Page Title</h1>' in response.body

0 comments on commit 7020cff

Please sign in to comment.