diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c8c3006 --- /dev/null +++ b/.travis.yml @@ -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: + - bbengfort@districtdatalabs.com + - tojeda@districtdatalabs.com + - rbilbro@districtdatalabs.com + on_success: change + on_failure: always diff --git a/README.md b/README.md index ef8d1dd..97f3474 100644 --- a/README.md +++ b/README.md @@ -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/) + + +[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 diff --git a/partisan/__init__.py b/partisan/__init__.py index e69de29..72e61fe 100644 --- a/partisan/__init__.py +++ b/partisan/__init__.py @@ -0,0 +1,26 @@ +# partisan +# The project module for the Partisan Discourse web application. +# +# Author: Benjamin Bengfort +# Created: Sat Jul 16 11:38:44 2016 -0400 +# +# Copyright (C) 2016 District Data Labs +# For license information, see LICENSE.txt +# +# ID: __init__.py [] benjamin@bengfort.com $ + +""" +The project module for the Partisan Discourse web application. +""" + +########################################################################## +## Imports +########################################################################## + +from .version import get_version + +########################################################################## +## Project Info +########################################################################## + +__version__ = get_version() diff --git a/partisan/settings/testing.py b/partisan/settings/testing.py index 6baaf9d..63c02f5 100644 --- a/partisan/settings/testing.py +++ b/partisan/settings/testing.py @@ -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', +# ) diff --git a/partisan/tests/__init__.py b/partisan/tests/__init__.py new file mode 100644 index 0000000..2ffb1b5 --- /dev/null +++ b/partisan/tests/__init__.py @@ -0,0 +1,18 @@ +# partisan.tests +# Tests for the complete partisan package. +# +# Author: Benjamin Bengfort +# Created: Sat Jul 16 11:36:08 2016 -0400 +# +# Copyright (C) 2016 District Data Labs +# For license information, see LICENSE.txt +# +# ID: __init__.py [] benjamin@bengfort.com $ + +""" +Tests for the complete partisan package. +""" + +########################################################################## +## Imports +########################################################################## diff --git a/partisan/tests/test_init.py b/partisan/tests/test_init.py new file mode 100644 index 0000000..18946f9 --- /dev/null +++ b/partisan/tests/test_init.py @@ -0,0 +1,57 @@ +# partisan.tests.test_init +# Initialization tests for the Partisan Discourse project +# +# Author: Benjamin Bengfort +# 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 [] benjamin@bengfort.com $ + +""" +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__) diff --git a/partisan/version.py b/partisan/version.py new file mode 100644 index 0000000..bc0fe5d --- /dev/null +++ b/partisan/version.py @@ -0,0 +1,49 @@ +# partisan.version +# Helper module for managing versioning information +# +# Author: Benjamin Bengfort +# Created: Sat Jul 16 11:37:27 2016 -0400 +# +# Copyright (C) 2015 District Data Labs +# For license information, see LICENSE.txt +# +# ID: version.py [] benjamin@bengfort.com $ + +""" +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)