What is Collab?
Collab is a Django project with a standard set of configurations to provide services to reusable apps.
What is included?
Core Collab comes with:
- Tagging (using a customized version of django-taggit)
- Search (using Haystack and Elasticsearch)
- Migrations (using South)
- Improved Caching
Setting up a development environment
- Python (>= 2.6)
Follow these steps to set up collab:
Clone this repo or a fork of it
git clone https://github.com/cfpb/collab.git cd collab
Make sure you have
easy_install -U pip pip install -U pip pip install -U virtualenv
You may have to prepend these commands with
sudo, depending on your setup.
Create a virtual environment for the project and install the necessary packages:
virtualenv --no-site-packages --distribute venv # creates the virtualenv named "venv" source venv/bin/activate # activates (places you in) the virtualenv pip install -r requirements.txt # installs main required packages for collab pip install -r requirements-test.txt # installs packages required for testing
Important Note: Anytime you restart your terminal and return to work on this project, you will need to reactivate the virtualenv by running the
source venv/bin/activatecommand from the collab root. See virtualenv for more details.
collab/local_settings.pyand edit to match your current environment. In particular, update the
DATABASESinformation. You will need to create the database you choose for the default schema.
elseblock) to set the database user and password to whatever user you have set up in MySQL (probably
rootwith no password, since it's local to your machine).
- Set a
SECRET KEY. This can be any string you want.
- If you have already set up any other child apps besides the four required, uncomment them in
Set up the database:
mysql.server start mysql -u <user> -e 'create database collab' python ./manage.py syncdb python ./manage.py syncdb --noinput --migrate python ./manage.py loaddata core/fixtures/core-test-fixtures.json
Optionally, you can create random users for local testing.
python ./manage.py create_users <number of users>
Run the Django server:
python ./manage.py runserver
Go to http://localhost:8000 in your browser and log in with user
You are a winner!
To run tests:
python manage.py test
Models should have a robust set of unit tests.
When writing unit tests for models, try to separate functionality which needs the DB from functionality which does not. Aim to avoid hitting the DB in a test for optimal results.
Views should have unit testing for functional parts of them: that is, try to extract functionality without side effects from the view functions, and then test those extracted functions.
Views should have system testing using WebTest for page interaction.