pythonph / jobs-board

PythonPH Jobs Board
MIT License
4 stars 1 forks source link

PythonPH Jobs Board

Build Status

Development

Requirements

Setup

  1. Install dependencies

    python3 -m venv venv
    source venv/bin/activate
    pip install -r reqs/development.txt
    npm install
  2. Setup database

    createuser -P pythonph
    createdb -O pythonph jobsboard
  3. Create configuration file

    cat .env
    DEBUG=True
    SECRET_KEY=secret
    DATABASE_URL=postgres://pythonph:password@localhost/jobsboard
    EMAIL_HOST_USER=<YOUR GMAIL EMAIL>
    EMAIL_HOST_PASSWORD=<YOUR GMAIL PASSWORD>
    
  4. Run migrations

    ./manage.py migrate
  5. Create admin user

    ./manage.py createsuperuser
  6. Run development server

    ./manage.py runserver

Docker Development (Alternative)

If you prefer to use docker for development, follow these steps instead.

Requirements

Setup

  1. Create configuration file

    cat .env
    DEBUG=True
    SECRET_KEY=secret
    DATABASE_URL=postgres://pythonph:password@postgres:5432/jobsboard
    EMAIL_HOST_USER=<YOUR GMAIL EMAIL>
    EMAIL_HOST_PASSWORD=<YOUR GMAIL PASSWORD>
  2. Run migrations and create admin user

    docker-compose run --rm -u "$(id -u):$(id -g)" web /bin/bash
    python3 manage.py migrate
    python3 manage.py createsuperuser
    exit
  3. Run development server

    docker-compose run --rm --service-ports web

Running the tests

We use py.test as our test runner. It is currently configured to run the files inside directories named tests inside the sub-apps.

Example: the tests for the jobsboard.jobs sub-app are inside jobsboard/jobs/tests/

Basic usage:

  py.test

py.test recreates the test DB every time. The time difference will become more noticeable once we have a lot of models in the app.

To get around this, we can add --reuse-db to skip the db creation step. Take note that this doesn't reuse the existing DB for the current run, but for the next one.

  py.test --reuse-db

If you introduced new fields or new models and use --reuse-db when running the test, you need to add --create-db so it will recreate the DB that includes you new fields or models.

  py.test --create-db

You may also combine --reuse-db and --create-db so that it will create a new DB for this run, but reuse the test DB in the succeeding runs.

  py.test --create-db --reuse-db

Styleguides

License

MIT