Commit 2e8a891c authored by Okhin's avatar Okhin Committed by GitHub
Browse files

Merge pull request #158 from political-memory/restructure_test

Attempt at fixing tests in the restructure branch
parents eeb5b064 029a6562
[run] [run]
omit = omit =
representatives_positions/contrib/* src/representatives_positions/contrib/*
representatives_recommendations/contrib/* src/representatives_recommendations/contrib/*
src/representatives/tests/*
src/representatives/migrations/*
src/representatives/contrib/francedata/tests/*
src/representatives/contrib/parltrack/tests/*
src/representatives_votes/tests/*
src/representatives_votes/migrations/*
...@@ -3,11 +3,11 @@ celerybeat-* ...@@ -3,11 +3,11 @@ celerybeat-*
core/static/libs/* core/static/libs/*
# libs # libs
static/libs src/memopol/static/libs/
# settings # settings
memopol/local_settings.py src/memopol/local_settings.py
memopol/config.json src/memopol/config.json
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
...@@ -18,6 +18,7 @@ __pycache__/ ...@@ -18,6 +18,7 @@ __pycache__/
# Virtualenv # Virtualenv
memopol_env memopol_env
.tox
# Installer logs # Installer logs
pip-log.txt pip-log.txt
......
export OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py export OPENSHIFT_PYTHON_WSGI_APPLICATION=src/memopol/wsgi.py
...@@ -7,25 +7,25 @@ set -xe ...@@ -7,25 +7,25 @@ set -xe
source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate source ${OPENSHIFT_HOMEDIR}app-root/runtime/dependencies/python/virtenv/bin/activate
pip install -U pip pip2 install --no-cache-dir -U pip
pip install -Ue ${OPENSHIFT_REPO_DIR} pip2 install --no-cache-dir -Ue ${OPENSHIFT_REPO_DIR}
mkdir -p ${OPENSHIFT_DATA_DIR}media mkdir -p ${OPENSHIFT_DATA_DIR}media
pushd ${OPENSHIFT_REPO_DIR} pushd ${OPENSHIFT_REPO_DIR}
if [ -f ${OPENSHIFT_DATA_DIR}sentry ]; then if [ -f ${OPENSHIFT_DATA_DIR}sentry ]; then
pip install raven pip2 --no-cache-dir install raven
fi fi
bin/install_client_deps.sh src/memopol/bin/install_client_deps.sh
mkdir -p wsgi/static mkdir -p wsgi/static
[ -f memopol/local_settings.py ] && rm memopol/local_settings.py [ -f src/memopol/local_settings.py ] && rm src/memopol/local_settings.py
cp .openshift/local_settings.py memopol/local_settings.py cp .openshift/local_settings.py src/memopol/local_settings.py
./manage.py migrate --noinput memopol migrate --noinput
./manage.py collectstatic --noinput memopol collectstatic --noinput
ln -sf ${OPENSHIFT_DATA_DIR}media wsgi/static/media ln -sf ${OPENSHIFT_DATA_DIR}media wsgi/static/media
ln -sf ${OPENSHIFT_DATA_DIR}compress/CACHE wsgi/static/collected/CACHE ln -sf ${OPENSHIFT_DATA_DIR}compress/CACHE wsgi/static/collected/CACHE
......
sudo: false sudo: false
<<<<<<< HEAD
env: env:
global: global:
- DJANGO_DEBUG=True - DJANGO_DEBUG=True
- DJANGO_SETTINGS_MODULE=memopol.settings - DJANGO_SETTINGS_MODULE=memopol.settings
matrix:
- TOXENV=qa
- TOXENV=docs
- TOXENV=py27
language: python language: python
python: python:
- '2.7' - '3.4'
services: services:
- postgresql - postgresql
install: install:
- pip install -U setuptools - travis_retry pip install -U pip
- pip install -e .[testing] - travis_retry pip install tox
- travis_retry pip freeze
before_script: before_script:
- bin/install_client_deps.sh
- psql -c "CREATE USER memopol WITH CREATEDB PASSWORD 'memopol';" -U postgres - psql -c "CREATE USER memopol WITH CREATEDB PASSWORD 'memopol';" -U postgres
- psql -c "CREATE DATABASE memopol WITH OWNER memopol;" -U postgres - psql -c "CREATE DATABASE memopol WITH OWNER memopol;" -U postgres
script: script:
- flake8 . --exclude '*/migrations,docs,static' --ignore E128 - travis_retry tox
- py.test memopol memopol_scores
- django-admin migrate
after_success: after_success:
- codecov - codecov
deploy: deploy:
......
...@@ -36,17 +36,17 @@ export DJANGO_DEBUG=True ...@@ -36,17 +36,17 @@ export DJANGO_DEBUG=True
export DJANGO_SETTINGS_MODULE=memopol.settings export DJANGO_SETTINGS_MODULE=memopol.settings
# Run django migration to create database # Run django migration to create database
./manage.py migrate memopol migrate
# Import sample data # Import sample data
./manage.py loaddata memopol/fixtures/data_sample.json memopol loaddata data_sample.json
echo echo
echo "You're all set!" echo "You're all set!"
echo "To start the application run the following from the repository root ($REPOROOT):" echo "To start the application run the following from the repository root ($REPOROOT):"
echo " source memopol_env/bin/activate" echo " source memopol_env/bin/activate"
echo " export DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings" echo " export DJANGO_DEBUG=True DJANGO_SETTINGS_MODULE=memopol.settings"
echo " ./manage.py runserver" echo " memopol runserver"
echo echo
echo "If you make changes, don't forget to run tests using:" echo "If you make changes, don't forget to run tests using:"
echo " flake8 . --exclude '*/migrations,docs,static' --ignore E128" echo " flake8 . --exclude '*/migrations,docs,static' --ignore E128"
......
...@@ -10,7 +10,7 @@ Authentication in the admin backend ...@@ -10,7 +10,7 @@ Authentication in the admin backend
If you haven't already, create a super-administrator If you haven't already, create a super-administrator
account with command:: account with command::
./manage.py createsuperuser memopol createsuperuser
Then use this account to authenticate in the Then use this account to authenticate in the
administration backend located in ``/admin``. administration backend located in ``/admin``.
......
...@@ -23,14 +23,14 @@ Customize settings ...@@ -23,14 +23,14 @@ Customize settings
Create a copy of the example local settings file:: Create a copy of the example local settings file::
$ cp memopol/local_settings.py.example memopol/local_settings.py $ cp src/memopol/local_settings.py.example src/memopol/local_settings.py
Edit ``memopol/local_settings.py`` to set directories, database settings and Edit ``src/memopol/local_settings.py`` to set directories, database settings and
allowed hosts. Setup your WSGI server to serve: allowed hosts. Setup your WSGI server to serve:
* Static files from the directory specified in the ``PUBLIC_DIR`` setting to the * Static files from the directory specified in the ``PUBLIC_DIR`` setting to the
``/static`` URL ``/static`` URL
* The memopol/wsgi.py WSGI application * The ``src/memopol/wsgi.py`` WSGI application
Initial memopol setup Initial memopol setup
===================== =====================
...@@ -41,7 +41,7 @@ From the repository root, install python dependencies:: ...@@ -41,7 +41,7 @@ From the repository root, install python dependencies::
Install client libraries:: Install client libraries::
$ bin/install_client_deps.sh $ src/memopol/bin/install_client_deps.sh
Setup the database schema:: Setup the database schema::
......
...@@ -38,8 +38,7 @@ To deploy the website, use a command like:: ...@@ -38,8 +38,7 @@ To deploy the website, use a command like::
cron-1.4 \ cron-1.4 \
postgresql-9.2 \ postgresql-9.2 \
-a yourappname \ -a yourappname \
-e OPENSHIFT_PYTHON_WSGI_APPLICATION=memopol/wsgi.py \ -e OPENSHIFT_PYTHON_WSGI_APPLICATION=src/memopol/wsgi.py \
--from-code https://github.com/political-memory/political_memory.git \
--no-git --no-git
This should create an app on openshift. Other commands would deploy it at once This should create an app on openshift. Other commands would deploy it at once
...@@ -87,7 +86,7 @@ Data provisionning ...@@ -87,7 +86,7 @@ Data provisionning
To fill up the representatives database table, either wait for the cron script To fill up the representatives database table, either wait for the cron script
to be executed, either do it manually:: to be executed, either do it manually::
$ rhc ssh -a yourappname 'cd app-root/repo/ && bin/update_all' $ rhc ssh -a yourappname 'cd app-root/repo && bin/update_all'
OpenShift is fun, login with ssh and look around if you're curious, you'll be OpenShift is fun, login with ssh and look around if you're curious, you'll be
able to recreate your app without much effort if you break it anyway. able to recreate your app without much effort if you break it anyway.
......
...@@ -44,6 +44,11 @@ Create a python virtual environment and activate it:: ...@@ -44,6 +44,11 @@ Create a python virtual environment and activate it::
$ source memopol_env/bin/activate $ source memopol_env/bin/activate
Alternatively, use the tox command::
$ tox -e py27
$ source .tox/py27/bin/activate
Clone the repository Clone the repository
==================== ====================
...@@ -132,7 +137,7 @@ Database migrations ensure the database schema is up to date with the project. ...@@ -132,7 +137,7 @@ Database migrations ensure the database schema is up to date with the project.
If you're not sure, you can run them anyway, they won't do any harm. Use the If you're not sure, you can run them anyway, they won't do any harm. Use the
following command:: following command::
$ ./manage.py migrate $ memopol migrate
Operations to perform: Operations to perform:
Synchronize unmigrated apps: django_filters, staticfiles, datetimewidget, autocomplete_light, messages, adminplus, compressor, humanize, django_extensions, constance, bootstrap3 Synchronize unmigrated apps: django_filters, staticfiles, datetimewidget, autocomplete_light, messages, adminplus, compressor, humanize, django_extensions, constance, bootstrap3
Apply all migrations: legislature, votes, database, admin, positions, sessions, representatives, auth, contenttypes, representatives_votes, taggit Apply all migrations: legislature, votes, database, admin, positions, sessions, representatives, auth, contenttypes, representatives_votes, taggit
...@@ -153,7 +158,7 @@ Provision with data ...@@ -153,7 +158,7 @@ Provision with data
You can load a small data sample for quick setup: You can load a small data sample for quick setup:
$ ./manage.py loaddata memopol/fixtures/small_sample.json $ memopol loaddata small_sample.json
Or actual data (takes a while):: Or actual data (takes a while)::
...@@ -164,7 +169,7 @@ Run the development server ...@@ -164,7 +169,7 @@ Run the development server
Run the development server:: Run the development server::
$ ./manage.py runserver $ memopol runserver
Performing system checks... Performing system checks...
......
...@@ -10,12 +10,28 @@ quickstart ...@@ -10,12 +10,28 @@ quickstart
<https://www.packtpub.com/application-development/continuous-delivery-and-devops-%E2%80%93-quickstart-guide-second-edition)>`_, <https://www.packtpub.com/application-development/continuous-delivery-and-devops-%E2%80%93-quickstart-guide-second-edition)>`_,
and I bet you'll order a paperback edition for reference ! and I bet you'll order a paperback edition for reference !
Testing
=======
Use the ``tox -l`` command to list tests::
$ pip install tox
$ cd political_memory/
$ tox -l
Use the ``tox -e`` command to execute a particular test suite::
$ tox -e py27
And use the ``tox`` command without argument to execute all test suites,
exactly like in CI.
Adding random recommendations Adding random recommendations
============================= =============================
:: ::
$ ./manage.py shell $ memopol shell
In [1]: from representatives_votes.models import Proposal In [1]: from representatives_votes.models import Proposal
In [2]: from votes.models import Recommendation In [2]: from votes.models import Recommendation
In [3]: import random In [3]: import random
...@@ -32,14 +48,14 @@ test run is. ...@@ -32,14 +48,14 @@ test run is.
To create test fixtures for representatives_positions, insert some Position To create test fixtures for representatives_positions, insert some Position
objects, and reduce the database with:: objects, and reduce the database with::
./manage.py remove_representatives_without_position memopol remove_representatives_without_position
./manage.py remove_groups_without_mandate memopol remove_groups_without_mandate
./manage.py remove_countries_without_group memopol remove_countries_without_group
For representatives_recommendations:: For representatives_recommendations::
./manage.py remove_proposals_without_recommendation memopol remove_proposals_without_recommendation
./manage.py remove_dossiers_without_proposal memopol remove_dossiers_without_proposal
./manage.py remove_representatives_without_vote memopol remove_representatives_without_vote
./manage.py remove_groups_without_mandate memopol remove_groups_without_mandate
./manage.py remove_countries_without_group memopol remove_countries_without_group
[pytest] [pytest]
DJANGO_SETTINGS_MODULE=memopol.settings DJANGO_SETTINGS_MODULE=memopol.settings
addopts = --cov-config .coveragerc --cov=. --create-db addopts = --cov-config .coveragerc --cov=src --create-db
from setuptools import setup from setuptools import setup, find_packages
setup(name='political-memory', setup(name='political-memory',
version='0.0.1', version='0.0.1',
description='OpenShift App', description='Political Memory Project Memopol',
packages=['political_memory'], packages=find_packages('src'),
package_dir={'political_memory': '.'}, package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
author='James Pic, Laurent Peuch, Arnaud Fabre, Nicolas Joyard', author='James Pic, Laurent Peuch, Arnaud Fabre, Nicolas Joyard',
author_email='cortex@worlddomination.be', author_email='cortex@worlddomination.be',
url='http://github.com/political-memory/political_memory/', url='http://github.com/political-memory/political_memory/',
...@@ -17,8 +19,6 @@ setup(name='political-memory', ...@@ -17,8 +19,6 @@ setup(name='political-memory',
'django-datetime-widget>=0.9,<1.0', 'django-datetime-widget>=0.9,<1.0',
'django-filter>=0.13,<0.14', 'django-filter>=0.13,<0.14',
'django-fontawesome>=0.2,<0.3', 'django-fontawesome>=0.2,<0.3',
'django-representatives-votes==0.0.24',
'django-representatives==0.0.35',
'django-rql-filter>=0.1.3,<0.2', 'django-rql-filter>=0.1.3,<0.2',
'django-taggit>=0.17,<0.18', 'django-taggit>=0.17,<0.18',
'django>=1.8,<1.9', 'django>=1.8,<1.9',
...@@ -43,12 +43,14 @@ setup(name='political-memory', ...@@ -43,12 +43,14 @@ setup(name='political-memory',
'pytest>=2,<3', 'pytest>=2,<3',
'pytest-django>=2,<3', 'pytest-django>=2,<3',
'pytest-cov>=2,<3', 'pytest-cov>=2,<3',
'mock-2.0.0',
] ]
}, },
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'memopol_import_positions = representatives_positions.contrib.import_positions:main', # noqa 'memopol_import_positions = representatives_positions.contrib.import_positions:main', # noqa
'memopol_import_recommendations = representatives_recommendations.contrib.import_recommendations:main', # noqa 'memopol_import_recommendations = representatives_recommendations.contrib.import_recommendations:main', # noqa
'memopol = memopol.manage:main',
] ]
} }
) )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment