diff --git a/.coveragerc b/.coveragerc index d1be2d0..02ebb99 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,14 +1,8 @@ [run] -omit = - ../*admin* - ../*urls* - retirement_api/migrations/* - setup.py - retirement_api/settings.py +source=retirement_api [report] - -exclude_lines = +exclude_lines= pragma: no cover def __unicode__ if __name__ == .__main__.: diff --git a/.travis.yml b/.travis.yml index c72aa90..0cdcd0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,18 +3,13 @@ python: - '2.7' cache: pip env: DJ_KEY=testkey -before_install: -- nvm use 6 install: -- pip install -r requirements.txt -- pip install coveralls +- pip install coveralls tox before_script: - - npm install -g bower gulp-cli - - bower install + - npm install -g bower gulp-cli + - bower install script: -- cp test_settings.py settings.py -- ./manage.py migrate -- coverage run --source='.' manage.py test +- tox - python2.7 setup.py bdist_wheel - ls dist/* after_success: diff --git a/README.md b/README.md index cb61504..9e6962b 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,10 @@ Tú puedes ver este app en español por poner `/es` al parte final del url. * [virtualenvwrapper](https://virtualenvwrapper.readthedocs.org/en/latest/) * [Node](http://nodejs.org/) * [Gulp](http://gulpjs.com/) + * [Bower](https://bower.io/) ### Code dependencies - * [Django 1.8](https://docs.djangoproject.com/en/1.8/) + * [Django 1.8-1.11](https://docs.djangoproject.com/en/1.11/) * [BeautifulSoup4](http://www.crummy.com/software/BeautifulSoup/bs4/doc/) * [Python-dateutil](https://dateutil.readthedocs.org/en/latest/) * [Requests](http://docs.python-requests.org/en/latest/) @@ -47,7 +48,7 @@ mkvirtualenv retirement git clone https://github.com/cfpb/retirement.git cd retirement setvirtualenvproject -pip install -r requirements.txt +pip install -e '.[testing]' ``` Build the front-end requirements and the JavaScript files. @@ -66,23 +67,24 @@ Fire up a development server. python manage.py runserver ``` -The "Before You Claim" page should load at `localhost:8000/retirement/before-you-claim/`. +The "Before You Claim" page should load at `localhost:8000/before-you-claim/`. ### Usage notes - The app is set up to run inside [consumerfinance.gov](http://www.consumerfinance.gov), so if you run it locally, some fonts may not load because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) policies. - The app sends http requests to the Social Security Administration's [Quick Calculator](http://www.ssa.gov/OACT/quickcalc/index.html) to get benefit estimates for the chart. ### How to run software tests -- You can use nose to run the Python test suite and see code coverage information: +- To run the Python tests, install [tox](https://tox.readthedocs.io/en/latest/) and then run it: + +```bash +tox +``` - ```bash - ./pytest.sh - ``` - You can run the JavaScript tests with: - ```bash - npm test - ``` +```bash +npm test +``` ## Additional documentation * [Front-end documentation](front-end.md) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 225958c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -beautifulsoup4==4.3.2 -coverage==3.7.1 -Django==1.8.9 -django-filter==0.9.2 -dj-database-url==0.4.2 -mock==1.0.1 -python-dateutil==2.2 -requests==2.9.1 -six==1.9.0 diff --git a/retirement_api/locale/es/LC_MESSAGES/django.mo b/retirement_api/locale/es/LC_MESSAGES/django.mo index 58048d1..d865445 100644 Binary files a/retirement_api/locale/es/LC_MESSAGES/django.mo and b/retirement_api/locale/es/LC_MESSAGES/django.mo differ diff --git a/retirement_api/locale/es/LC_MESSAGES/django.po b/retirement_api/locale/es/LC_MESSAGES/django.po index f3b52c8..c69377f 100644 --- a/retirement_api/locale/es/LC_MESSAGES/django.po +++ b/retirement_api/locale/es/LC_MESSAGES/django.po @@ -859,10 +859,6 @@ msgstr "Nuestra herramienta aplica aumentos en sus beneficios estimados inmediat msgid "The tool gives estimates for people ages 22 to 70" msgstr "La herramienta proporciona estimaciones para las personas entre las edades de 22 a 70 años" -#: -msgid "about" -msgstr "/retirement/before-you-claim/about/es/" - #: msgid "Planning for Retirement: Before you claim" msgstr "Planifique para su Jubilación: Antes de solicitar" diff --git a/retirement_api/templates/base.html b/retirement_api/templates/base.html deleted file mode 100644 index 8b8021e..0000000 --- a/retirement_api/templates/base.html +++ /dev/null @@ -1,181 +0,0 @@ - -{% load i18n %} -{% load staticfiles %} -{% trans page.title as TITLE %} -{% trans "Yes" as YES %} -{% trans "No" as NO %} -{% trans "Not Sure" as NOTSURE %} -{% trans "Step" as STEP %} - - - - - - - - -
- - - -- + {% trans "Where do these numbers come from?" %}
diff --git a/retirement_api/templates/standalone/base_update.html b/retirement_api/templates/retirement_api/standalone/base_update.html similarity index 100% rename from retirement_api/templates/standalone/base_update.html rename to retirement_api/templates/retirement_api/standalone/base_update.html diff --git a/retirement_api/templates/standalone/share_box.html b/retirement_api/templates/retirement_api/standalone/share_box.html similarity index 100% rename from retirement_api/templates/standalone/share_box.html rename to retirement_api/templates/retirement_api/standalone/share_box.html diff --git a/retirement_api/templates/standalone/share_links.html b/retirement_api/templates/retirement_api/standalone/share_links.html similarity index 100% rename from retirement_api/templates/standalone/share_links.html rename to retirement_api/templates/retirement_api/standalone/share_links.html diff --git a/retirement_api/templates/standalone/on-demand/footer.html b/retirement_api/templates/standalone/on-demand/footer.html deleted file mode 100644 index cb9f855..0000000 --- a/retirement_api/templates/standalone/on-demand/footer.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - diff --git a/retirement_api/templates/standalone/share_block.html b/retirement_api/templates/standalone/share_block.html deleted file mode 100644 index b7e4834..0000000 --- a/retirement_api/templates/standalone/share_block.html +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/retirement_api/tests/test_views.py b/retirement_api/tests/test_views.py index 2f68858..b1c2e1f 100644 --- a/retirement_api/tests/test_views.py +++ b/retirement_api/tests/test_views.py @@ -5,23 +5,13 @@ import mock -from django.test import Client from django.core.urlresolvers import reverse from django.shortcuts import render_to_response from django.template import RequestContext from django.test import TestCase # import unittest from django.http import HttpRequest -from django.conf import settings -client = Client() -# if __name__ == '__main__': -# BASE_DIR = '~/Projects/retirement1.6/retirement/retirement_api' -# else: -# BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) -sys.path.append(BASE_DIR) -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from retirement_api.views import (param_check, income_check, @@ -62,11 +52,11 @@ class ViewTests(TestCase): return_keys = ['data', 'error'] def test_base_view(self): - url = reverse('claiming') - response = client.get(url) + url = reverse('retirement_api:claiming') + response = self.client.get(url) self.assertTrue(response.status_code == 200) - url = reverse('claiming_es') - response = client.get(url) + url = reverse('retirement_api:claiming_es') + response = self.client.get(url) self.assertTrue(response.status_code == 200) def test_param_check(self): @@ -141,9 +131,9 @@ def test_estimator_query_data_bad_income(self): self.assertTrue(response.status_code == 400) def test_about_pages(self): - url = reverse('retirement_about') - response = client.get(url) + url = reverse('retirement_api:about') + response = self.client.get(url) self.assertTrue(response.status_code == 200) - url = reverse('retirement_about_es', kwargs={'language': 'es'}) - response = client.get(url) + url = reverse('retirement_api:about_es', kwargs={'language': 'es'}) + response = self.client.get(url) self.assertTrue(response.status_code == 200) diff --git a/retirement_api/tests/urls.py b/retirement_api/tests/urls.py new file mode 100644 index 0000000..41a89bd --- /dev/null +++ b/retirement_api/tests/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import include, url +from django.contrib import admin + +import retirement_api.urls + + +urlpatterns = [ + url(r'^', include(retirement_api.urls, 'retirement_api')), + url(r'^admin/', include(admin.site.urls)), +] diff --git a/retirement_api/urls.py b/retirement_api/urls.py index 53763dd..d55e344 100644 --- a/retirement_api/urls.py +++ b/retirement_api/urls.py @@ -1,44 +1,19 @@ -from django.conf.urls import patterns, include, url -from django.conf import settings -from django.contrib import admin +from django.conf.urls import url + +from retirement_api.views import about, claiming, estimator + + +app_name = 'retirement_api' -try: - STANDALONE = settings.STANDALONE -except AttributeError: # pragma: no cover - STANDALONE = False urlpatterns = [ - url(r'^before-you-claim/about/$', 'retirement_api.views.about', - name='retirement_about'), - url(r'^before-you-claim/about/es/$', 'retirement_api.views.about', - {'language': 'es'}, name='retirement_about_es'), - url(r'^before-you-claim/$', 'retirement_api.views.claiming', - name='claiming'), - url(r'^before-you-claim/es/$', 'retirement_api.views.claiming', - {'es': True}, name='claiming_es'), + url(r'^before-you-claim/about/$', about, name='about'), + url(r'^before-you-claim/about/es/$', about, {'language': 'es'}, + name='about_es'), + url(r'^before-you-claim/$', claiming, name='claiming'), + url(r'^before-you-claim/es/$', claiming, {'es': True}, name='claiming_es'), url(r'^retirement-api/estimator/(?P