Skip to content

Commit

Permalink
travis, tests, and badges
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Jul 16, 2016
1 parent 5277a6e commit 80822db
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 7 deletions.
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: python
python:
- '3.5.1'

before_install:
- pip install nose
- pip install coverage
- pip install coveralls

install: pip install -r requirements.txt

before_script:
- psql -c 'create database partisan;' -U postgres

script: make test

after_success: coveralls

env:
global:
- DJANGO_SETTINGS_MODULE=partisan.settings.testing
- SECRET_KEY=supersecretkey
- DATABASE_URL=postgres://localhost/partisan
- EMAIL_HOST_USER=''
- EMAIL_HOST_PASSWORD=''
- GOOGLE_OAUTH2_KEY=''
- GOOGLE_OAUTH2_SECRET=''

notifications:
email:
recipients:
- [email protected]
- [email protected]
- [email protected]
on_success: change
on_failure: always
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@

**A web application that identifies party in political discourse and an example of operationalized machine learning.**

[![Political Parties](docs/img/partisan.jpg)](https://flic.kr/p/a3bXVU)
[![Build Status][travis_img]][travis_href]
[![Coverage Status][coveralls_img]][coveralls_href]
[![Stories in Ready][waffle_img]][waffle_href]

[![Political Parties](docs/img/partisan.jpg)][partisan.jpg]

## About

This small web application is intended to highlight how to operationalize machine learning models in a web application. Through the lens of a political classifier we see how models can be managed and stored inside of Django for per-user and global modeling.
This small web application is intended to highlight how to operationalize machine learning models in a web application. Through the lens of a political classifier we see how models can be managed and stored inside of Django for per-user and global modeling.

### Attribution

The image used in this README, [Partisan Fail][https://flic.kr/p/a3bXVU] by [David Colarusso](https://www.flickr.com/photos/dcolarusso/) is licensed under [CC BY-NC 2.0](https://creativecommons.org/licenses/by-nc/2.0/)
The image used in this README, [Partisan Fail][partisan.jpg] by [David Colarusso](https://www.flickr.com/photos/dcolarusso/) is licensed under [CC BY-NC 2.0](https://creativecommons.org/licenses/by-nc/2.0/)

<!-- References -->
[travis_img]: https://travis-ci.org/DistrictDataLabs/partisan-discourse.svg
[travis_href]: https://travis-ci.org/DistrictDataLabs/partisan-discourse
[waffle_img]: https://badge.waffle.io/DistrictDataLabs/partisan-discourse.png?label=ready&title=Ready
[waffle_href]: https://waffle.io/DistrictDataLabs/partisan-discourse
[coveralls_img]: https://coveralls.io/repos/github/DistrictDataLabs/partisan-discourse/badge.svg?branch=master
[coveralls_href]:https://coveralls.io/github/DistrictDataLabs/partisan-discourse?branch=master
[partisan.jpg]: https://flic.kr/p/a3bXVU
26 changes: 26 additions & 0 deletions partisan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# partisan
# The project module for the Partisan Discourse web application.
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sat Jul 16 11:38:44 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: __init__.py [] [email protected] $

"""
The project module for the Partisan Discourse web application.
"""

##########################################################################
## Imports
##########################################################################

from .version import get_version

##########################################################################
## Project Info
##########################################################################

__version__ = get_version()
8 changes: 4 additions & 4 deletions partisan/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
## Django REST Framework
##########################################################################

REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
)
# REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = (
# 'rest_framework.authentication.SessionAuthentication',
# 'rest_framework.authentication.BasicAuthentication',
# )
18 changes: 18 additions & 0 deletions partisan/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# partisan.tests
# Tests for the complete partisan package.
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sat Jul 16 11:36:08 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: __init__.py [] [email protected] $

"""
Tests for the complete partisan package.
"""

##########################################################################
## Imports
##########################################################################
57 changes: 57 additions & 0 deletions partisan/tests/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# partisan.tests.test_init
# Initialization tests for the Partisan Discourse project
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sat Jul 16 11:36:36 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: test_init.py [] [email protected] $

"""
Initialization tests for the Partisan Discourse project
"""

##########################################################################
## Imports
##########################################################################

from unittest import TestCase

##########################################################################
## Module variables
##########################################################################

EXPECTED_VERSION = "0.1"

##########################################################################
## Initialization Tests
##########################################################################

class InitializationTests(TestCase):
"""
Some basic partisan tests
"""

def test_sanity(self):
"""
Check that the world is sane and 2+2=4
"""
self.assertEqual(2+2, 4)

def test_import(self):
"""
Ensure the partisan module can be imported
"""
try:
import partisan
except ImportError:
self.fail("Could not import the partisan module.")

def test_version(self):
"""
Assert that test and package versions match
"""
import partisan
self.assertEqual(EXPECTED_VERSION, partisan.__version__)
49 changes: 49 additions & 0 deletions partisan/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# partisan.version
# Helper module for managing versioning information
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sat Jul 16 11:37:27 2016 -0400
#
# Copyright (C) 2015 District Data Labs
# For license information, see LICENSE.txt
#
# ID: version.py [] [email protected] $

"""
Helper module for managing versioning information
"""

##########################################################################
## Versioning
##########################################################################

__version_info__ = {
'major': 0,
'minor': 1,
'micro': 0,
'releaselevel': 'final',
'serial': 0,
}


def get_version(short=False):
"""
Returns the version from the version info.
"""
if __version_info__['releaselevel'] not in ('alpha', 'beta', 'final'):
raise ValueError(
"unknown release level '{}', select alpha, beta, or final.".format(
__version_info__['releaselevel']
)
)

vers = ["{major}.{minor}".format(**__version_info__)]

if __version_info__['micro']:
vers.append(".{micro}".format(**__version_info__))

if __version_info__['releaselevel'] != 'final' and not short:
vers.append('{}{}'.format(__version_info__['releaselevel'][0],
__version_info__['serial']))

return ''.join(vers)

0 comments on commit 80822db

Please sign in to comment.