Collab is a Django project with a standard set of configurations to provide services to reusable apps.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
collab
core
templates
.gitignore
.travis.yml
AUTHORS
CONTRIBUTING.md
COPYING.txt
README.md
TERMS.md
manage.py
requirements-test.txt
requirements.txt
setup.py

README.md

Collab

Build Status

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:

Setting up a development environment

Requirements:

  • Python (>= 2.6)
  • Mysql

Follow these steps to set up collab:

  1. Clone this repo or a fork of it

    git clone https://github.com/cfpb/collab.git
    cd collab
  2. Make sure you have pip and virtualenv installed:

    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.

  3. 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/activate command from the collab root. See virtualenv for more details.

  4. Copy collab/local_settings_template.py to collab/local_settings.py and edit to match your current environment. In particular, update the DATABASES information. You will need to create the database you choose for the default schema.

    • Edit DATABASES (in the else block) to set the database user and password to whatever user you have set up in MySQL (probably root with 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 INSTALLED_APPS.
  5. Set up the database:

    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>
  6. Run the Django server:

    python ./manage.py runserver
  7. Go to http://localhost:8000 in your browser and log in with user test1@example.com and password 1.

  8. You are a winner!

Testing

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.