Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Support tests running in Django 2.2 (#251)
Browse files Browse the repository at this point in the history
* Fixes the two test failures that the Django 2.2 upgrade introduced

* This commit has had `black` (https://github.com/psf/black), the autoformatter, run on the `retirement_api` package and `setup.py`

* It also adds `black --check` to the `tox` `lint` environment and adds a section in `CONTRIBUTING.md` about code style and tools.
  • Loading branch information
cwdavies authored Mar 27, 2020
1 parent 3e690a2 commit 6b9c165
Show file tree
Hide file tree
Showing 33 changed files with 1,599 additions and 1,130 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This project no longer uses `CHANGELOG.md` to track release changes. See the project repository release history at: https://github.com/cfpb/retirement/releases

To see the legacy version of this file, visit: https://github.com/cfpb/retirement/blob/0.7.2/CHANGELOG.md
To see the legacy version of this file, visit: https://github.com/cfpb/retirement/blob/0.11.0/CHANGELOG.md

or, from the command line: `git show 0.7.2:CHANGELOG.md`
or, from the command line: `git show 0.11.0:CHANGELOG.md`
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,22 @@ information visit the [Autoprefixer documentation site]
- Icons: We currently use icon fonts to deliver scalable icons. Browsers that
do not support icon fonts unfortunately do not receive backups but we try to
always pair icons with text.

## Style

This project uses [`black`](https://github.com/psf/black) to format code,
[`isort`](https://github.com/timothycrosley/isort) to format imports,
and [`flake8`](https://gitlab.com/pycqa/flake8).

You can format code and imports by calling:

```
black retirement_api
isort --recursive retirement_api
```

And you can check for style, import order, and other linting by using:

```
tox -e lint
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Tú puedes ver este app en español por poner `/es` al parte final del url.
* [Bower](https://bower.io/)

### Code dependencies
* [Django 1.11](https://docs.djangoproject.com/en/1.11/)
* [Django 2.2](https://docs.djangoproject.com/en/2.2/)
* [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/)
Expand Down
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[tool.black]
line-length = 79
target-version = ['py36', 'py38']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.tox
| \*.egg-info
| _build
| build
| dist
| migrations
| site
| \*.json
| \*.csv
)/
)
'''

[build-system]
requires = ["setuptools", "wheel"]
20 changes: 14 additions & 6 deletions retirement_api/admin.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
#!/usr/bin/env python
from django.contrib import admin
from retirement_api.models import (Page, Question, Step,
Calibration, AgeChoice, Tooltip)

from retirement_api.models import (
AgeChoice,
Calibration,
Page,
Question,
Step,
Tooltip,
)


class PageAdmin(admin.ModelAdmin):
list_display = ('title', 'h1', 'intro')
list_display = ("title", "h1", "intro")


class AgeChoiceAdmin(admin.ModelAdmin):
list_display = ('age', 'aside')
list_display = ("age", "aside")


class QuestionAdmin(admin.ModelAdmin):
list_display = ('title', 'question', 'workflow_state')
list_display = ("title", "question", "workflow_state")


class TooltipAdmin(admin.ModelAdmin):
list_display = ('title', 'text')
list_display = ("title", "text")


admin.site.register(Page, PageAdmin)
admin.site.register(Question, QuestionAdmin)
Expand Down
69 changes: 69 additions & 0 deletions retirement_api/data/awi_series_2020.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Year,Index
1951,2799.16
1952,2973.32
1953,3139.44
1954,3155.64
1955,3301.44
1956,3532.36
1957,3641.72
1958,3673.80
1959,3855.80
1960,4007.12
1961,4086.76
1962,4291.40
1963,4396.64
1964,4576.32
1965,4658.72
1966,4938.36
1967,5213.44
1968,5571.76
1969,5893.76
1970,6186.24
1971,6497.08
1972,7133.80
1973,7580.16
1974,8030.76
1975,8630.92
1976,9226.48
1977,9779.44
1978,10556.03
1979,11479.46
1980,12513.46
1981,13773.10
1982,14531.34
1983,15239.24
1984,16135.07
1985,16822.51
1986,17321.82
1987,18426.51
1988,19334.04
1989,20099.55
1990,21027.98
1991,21811.60
1992,22935.42
1993,23132.67
1994,23753.53
1995,24705.66
1996,25913.90
1997,27426.00
1998,28861.44
1999,30469.84
2000,32154.82
2001,32921.92
2002,33252.09
2003,34064.95
2004,35648.55
2005,36952.94
2006,38651.41
2007,40405.48
2008,41334.97
2009,40711.61
2010,41673.83
2011,42979.61
2012,44321.67
2013,44888.16
2014,46481.52
2015,48098.63
2016,48642.15
2017,50321.89
2018,52145.80
1 change: 1 addition & 0 deletions retirement_api/data/awi_series_2020.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"1951": "2799.16", "1952": "2973.32", "1953": "3139.44", "1954": "3155.64", "1955": "3301.44", "1956": "3532.36", "1957": "3641.72", "1958": "3673.80", "1959": "3855.80", "1960": "4007.12", "1961": "4086.76", "1962": "4291.40", "1963": "4396.64", "1964": "4576.32", "1965": "4658.72", "1966": "4938.36", "1967": "5213.44", "1968": "5571.76", "1969": "5893.76", "1970": "6186.24", "1971": "6497.08", "1972": "7133.80", "1973": "7580.16", "1974": "8030.76", "1975": "8630.92", "1976": "9226.48", "1977": "9779.44", "1978": "10556.03", "1979": "11479.46", "1980": "12513.46", "1981": "13773.10", "1982": "14531.34", "1983": "15239.24", "1984": "16135.07", "1985": "16822.51", "1986": "17321.82", "1987": "18426.51", "1988": "19334.04", "1989": "20099.55", "1990": "21027.98", "1991": "21811.60", "1992": "22935.42", "1993": "23132.67", "1994": "23753.53", "1995": "24705.66", "1996": "25913.90", "1997": "27426.00", "1998": "28861.44", "1999": "30469.84", "2000": "32154.82", "2001": "32921.92", "2002": "33252.09", "2003": "34064.95", "2004": "35648.55", "2005": "36952.94", "2006": "38651.41", "2007": "40405.48", "2008": "41334.97", "2009": "40711.61", "2010": "41673.83", "2011": "42979.61", "2012": "44321.67", "2013": "44888.16", "2014": "46481.52", "2015": "48098.63", "2016": "48642.15", "2017": "50321.89", "2018": "52145.80"}
14 changes: 14 additions & 0 deletions retirement_api/data/early_penalty_2020.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
YOB,FRA,reduction_months,primary_pia,primary_pct_reduction,spouse_pia,spouse_pct_reduction
1937 or earlier,65,36,$800,20.00%,$375,25.00%
1938,65 and 2 months,38,791,20.83%,370,25.83%
1939,65 and 4 months,40,783,21.67%,366,26.67%
1940,65 and 6 months,42,775,22.50%,362,27.50%
1941,65 and 8 months,44,766,23.33%,358,28.33%
1942,65 and 10 months,46,758,24.17%,354,29.17%
1943-1954,66,48,750,25.00%,350,30.00%
1955,66 and 2 months,50,741,25.83%,345,30.83%
1956,66 and 4 months,52,733,26.67%,341,31.67%
1957,66 and 6 months,54,725,27.50%,337,32.50%
1958,66 and 8 months,56,716,28.33%,333,33.33%
1959,66 and 10 months,58,708,29.17%,329,34.17%
1960 and later,67,60,700,30.00%,325,35.00%
1 change: 1 addition & 0 deletions retirement_api/data/early_penalty_2020.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"1937 or earlier": {"FRA": "65", "reduction_months": "36", "primary_pia": "$800", "primary_pct_reduction": "20.00%", "spouse_pia": "$375", "spouse_pct_reduction": "25.00%"}, "1938": {"FRA": "65 and 2 months", "reduction_months": "38", "primary_pia": "791", "primary_pct_reduction": "20.83%", "spouse_pia": "370", "spouse_pct_reduction": "25.83%"}, "1939": {"FRA": "65 and 4 months", "reduction_months": "40", "primary_pia": "783", "primary_pct_reduction": "21.67%", "spouse_pia": "366", "spouse_pct_reduction": "26.67%"}, "1940": {"FRA": "65 and 6 months", "reduction_months": "42", "primary_pia": "775", "primary_pct_reduction": "22.50%", "spouse_pia": "362", "spouse_pct_reduction": "27.50%"}, "1941": {"FRA": "65 and 8 months", "reduction_months": "44", "primary_pia": "766", "primary_pct_reduction": "23.33%", "spouse_pia": "358", "spouse_pct_reduction": "28.33%"}, "1942": {"FRA": "65 and 10 months", "reduction_months": "46", "primary_pia": "758", "primary_pct_reduction": "24.17%", "spouse_pia": "354", "spouse_pct_reduction": "29.17%"}, "1943-1954": {"FRA": "66", "reduction_months": "48", "primary_pia": "750", "primary_pct_reduction": "25.00%", "spouse_pia": "350", "spouse_pct_reduction": "30.00%"}, "1955": {"FRA": "66 and 2 months", "reduction_months": "50", "primary_pia": "741", "primary_pct_reduction": "25.83%", "spouse_pia": "345", "spouse_pct_reduction": "30.83%"}, "1956": {"FRA": "66 and 4 months", "reduction_months": "52", "primary_pia": "733", "primary_pct_reduction": "26.67%", "spouse_pia": "341", "spouse_pct_reduction": "31.67%"}, "1957": {"FRA": "66 and 6 months", "reduction_months": "54", "primary_pia": "725", "primary_pct_reduction": "27.50%", "spouse_pia": "337", "spouse_pct_reduction": "32.50%"}, "1958": {"FRA": "66 and 8 months", "reduction_months": "56", "primary_pia": "716", "primary_pct_reduction": "28.33%", "spouse_pia": "333", "spouse_pct_reduction": "33.33%"}, "1959": {"FRA": "66 and 10 months", "reduction_months": "58", "primary_pia": "708", "primary_pct_reduction": "29.17%", "spouse_pia": "329", "spouse_pct_reduction": "34.17%"}, "1960 and later": {"FRA": "67", "reduction_months": "60", "primary_pia": "700", "primary_pct_reduction": "30.00%", "spouse_pia": "325", "spouse_pct_reduction": "35.00%"}}
46 changes: 46 additions & 0 deletions retirement_api/data/ss_cola_2020.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Year,COLA
1975,8.0
1976,6.4
1977,5.9
1978,6.5
1979,9.9
1980,14.3
1981,11.2
1982,7.4
1983,3.5
1984,3.5
1985,3.1
1986,1.3
1987,4.2
1988,4.0
1989,4.7
1990,5.4
1991,3.7
1992,3.0
1993,2.6
1994,2.8
1995,2.6
1996,2.9
1997,2.1
1998,1.3
1999,2.5
2000,3.5
2001,2.6
2002,1.4
2003,2.1
2004,2.7
2005,4.1
2006,3.3
2007,2.3
2008,5.8
2009,0.0
2010,0.0
2011,3.6
2012,1.7
2013,1.5
2014,1.7
2015,0.0
2016,0.3
2017,2.0
2018,2.8
2019,1.6
1 change: 1 addition & 0 deletions retirement_api/data/ss_cola_2020.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"1975": "8.0", "1976": "6.4", "1977": "5.9", "1978": "6.5", "1979": "9.9", "1980": "14.3", "1981": "11.2", "1982": "7.4", "1983": "3.5", "1984": "3.5", "1985": "3.1", "1986": "1.3", "1987": "4.2", "1988": "4.0", "1989": "4.7", "1990": "5.4", "1991": "3.7", "1992": "3.0", "1993": "2.6", "1994": "2.8", "1995": "2.6", "1996": "2.9", "1997": "2.1", "1998": "1.3", "1999": "2.5", "2000": "3.5", "2001": "2.6", "2002": "1.4", "2003": "2.1", "2004": "2.7", "2005": "4.1", "2006": "3.3", "2007": "2.3", "2008": "5.8", "2009": "0.0", "2010": "0.0", "2011": "3.6", "2012": "1.7", "2013": "1.5", "2014": "1.7", "2015": "0.0", "2016": "0.3", "2017": "2.0", "2018": "2.8", "2019": "1.6"}
8 changes: 4 additions & 4 deletions retirement_api/management/commands/check_ssa.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.core.management.base import BaseCommand

from retirement_api.utils import check_api


COMMAND_HELP = """Sends a test post to SSA's Quick Calculator \
and checks the results to make sure we're getting valid results."""
PARSER_HELP = """Specify server to use. default is 'build', \
Expand All @@ -12,10 +14,8 @@ class Command(BaseCommand):
help = COMMAND_HELP

def add_arguments(self, parser):
parser.add_argument('--server',
default='build',
help=PARSER_HELP)
parser.add_argument("--server", default="build", help=PARSER_HELP)

def handle(self, *args, **options):
result = check_api.run(options['server'])
result = check_api.run(options["server"])
self.stdout.write(check_api.build_msg(result))
12 changes: 8 additions & 4 deletions retirement_api/management/commands/check_ssa_values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.core.management.base import BaseCommand

from retirement_api.utils import ssa_check


HELP_NOTE = """Checks a range of results from SSA's Quick Calculator \
to detect whether benefit formulas have changed."""
END_NOTE = "Checked SSA values; see results at {0}"
Expand All @@ -10,12 +12,14 @@ class Command(BaseCommand):
help = HELP_NOTE

def add_arguments(self, parser):
parser.add_argument('--recalibrate',
action='store_true',
help='Create a new calibration file')
parser.add_argument(
"--recalibrate",
action="store_true",
help="Create a new calibration file",
)

def handle(self, *args, **options):
if options['recalibrate']:
if options["recalibrate"]:
endmsg = ssa_check.run_tests(recalibrate=True)
else:
endmsg = ssa_check.run_tests()
Expand Down
8 changes: 4 additions & 4 deletions retirement_api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import django

from django.db import models, migrations

Expand Down Expand Up @@ -84,16 +84,16 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='page',
name='step1',
field=models.ForeignKey(related_name='step1', blank=True, to='retirement_api.Step', null=True),
field=models.ForeignKey(related_name='step1', blank=True, to='retirement_api.Step', null=True, on_delete=django.db.models.deletion.CASCADE),
),
migrations.AddField(
model_name='page',
name='step2',
field=models.ForeignKey(related_name='step2', blank=True, to='retirement_api.Step', null=True),
field=models.ForeignKey(related_name='step2', blank=True, to='retirement_api.Step', null=True, on_delete=django.db.models.deletion.CASCADE),
),
migrations.AddField(
model_name='page',
name='step3',
field=models.ForeignKey(related_name='step3', blank=True, to='retirement_api.Step', null=True),
field=models.ForeignKey(related_name='step3', blank=True, to='retirement_api.Step', null=True, on_delete=django.db.models.deletion.CASCADE),
),
]
Loading

0 comments on commit 6b9c165

Please sign in to comment.