sc3/cookcountyjail — pull request #189 by bepetersn (2013-10-29 08:18:49+00:00)
Title: VS 2.1.1 -- DailyPopulationChanges (DPC) model, POST API, tests for both

## Summary of Changes

### API
- opened up '/daily_population_changes' URI for POST calls
- added test to make sure POST calls can be made, and that data POSTED can be retrieved

### Model
- re-purposed DPC model as a wrapper around a csv file
- made DPC model select a path for a database file behind the scenes, based on Flask's config and env variables
- added a few tests to make sure DPC model behaves as expected

## Usage

>>> from ccj.models.daily_population_changes import DailyPopulationChanges as DPC
>>> # Chooses a file behind the scenes; see 'ccj/config.py' for the implementation.
>>> # The most important thing is to set the TESTING env. variable before any import statement.
>>> dpc = DPC()
>>> # You can check which file is being used by checking the private '_path' variable.
>>> dpc._path
'/tmp/dpc.json'
>>> dpc.query()
[]
>>> entry = {'date': '2013-10-18', 'booked_male_as':'9'}
>>> dpc.store(entry)
>>> dpc.query()
[{'Date': '2013-10-18', 'Booked': {'Male': {'As': '9'}}}]