Skip to content

Commit 267c457

Browse files
authored
Merge pull request #128 from schbetsy/upgrade-everything
Add Django 1.11 compatibility, and other modernization
2 parents fffe6d6 + 927adbd commit 267c457

20 files changed

+225
-545
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ build/
1313
develop-eggs/
1414
dist/
1515
eggs/
16+
.eggs/
1617
parts/
1718
sdist/
1819
var/
@@ -47,6 +48,7 @@ coverage.xml
4748
*.log
4849
*.pot
4950
oah
51+
*.sqlite3
5052

5153
# Sphinx documentation
5254
docs/_build/

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ language: python
22
python:
33
- 2.7.14
44
install:
5-
- pip install -r requirements/test.txt
5+
- pip install tox
66
- pip install coveralls
77
script:
8-
- export DJANGO_SETTINGS_MODULE=settings_for_testing
9-
- coverage run manage.py test
8+
- tox
109
- python2.7 setup.py bdist_wheel
1110
after_success:
1211
- coveralls

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ These instructions are for installation on a Mac with OS X Yosemite (version 10.
2323

2424
**Optional**
2525
* [Homebrew](http://brew.sh)
26-
* [MySQL](http://www.mysql.com)
27-
* [MySQL Python](http://mysql-python.sourceforge.net/)
2826

2927
#### Steps for firing up Django
3028
- It's useful to create a [virtualenv](https://virtualenv.pypa.io/en/latest/) virtual environment to keep Python dependencies sandboxed:
@@ -40,7 +38,7 @@ cd ~/workspace
4038
git clone https://github.com/cfpb/owning-a-home-api.git
4139
cd owning-a-home-api/
4240
setvirtualenvproject
43-
pip install -r requirements/test.txt
41+
pip install -e '.[testing]'
4442
```
4543

4644
- Initialize your database, load some basic data and launch a development server:
@@ -69,14 +67,25 @@ This repo contains limited data, but you can explore mortgage interest rates in
6967

7068
## Deeper dive
7169

72-
You can find more about using the API endpoints and the optional use of a MySQL database in our [API documentation pages](https://cfpb.github.io/owning-a-home-api/).
70+
You can find [additional documentation for the `ratechecker` app](ratechecker).
7371

74-
See also [additional documentation for the `ratechecker` app](ratechecker).
7572

76-
## Testing
77-
You can run Python unit tests and see code coverage by running:
73+
## Running Tests
74+
75+
If you have [Tox](https://tox.readthedocs.io/en/latest/) installed (recommended),
76+
you can run the specs for this project with the `tox` command.
77+
78+
If not, this command will run the specs on the python version your local
79+
environment has installed: `./manage.py test`.
80+
81+
If you run the tests via Tox, it will automatically display spec coverage information.
82+
To get test coverage information outside of Tox, install [Coverage.py](https://coverage.readthedocs.io/en/coverage-4.5.1a/)
83+
and run these commands:
84+
7885
```
79-
./pytest.sh
86+
coverage erase
87+
coverage run manage.py test
88+
coverage report
8089
```
8190

8291
## Contributions

countylimits/data_collection/county_data_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def get_current_log():
1515
changelog_response = requests.get(CENSUS_CHANGELOG)
1616
changelog_response.raise_for_status()
17-
soup = bs(changelog_response.text, 'lxml')
17+
soup = bs(changelog_response.text, 'html.parser')
1818
return soup.find("div", {"id": CHANGELOG_ID}).text
1919

2020

Lines changed: 50 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,51 @@
11
# -*- coding: utf-8 -*-
2-
from south.utils import datetime_utils as datetime
3-
from south.db import db
4-
from south.v2 import SchemaMigration
5-
from django.db import models
6-
7-
8-
class Migration(SchemaMigration):
9-
10-
def forwards(self, orm):
11-
# Adding model 'State'
12-
db.create_table(u'countylimits_state', (
13-
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
14-
('state_fips', self.gf('django.db.models.fields.CharField')(max_length=2)),
15-
('state_abbr', self.gf('localflavor.us.models.USStateField')(max_length=2)),
16-
))
17-
db.send_create_signal(u'countylimits', ['State'])
18-
19-
# Adding model 'County'
20-
db.create_table(u'countylimits_county', (
21-
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
22-
('county_fips', self.gf('django.db.models.fields.CharField')(max_length=3)),
23-
('county_name', self.gf('django.db.models.fields.CharField')(max_length=100)),
24-
('state', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['countylimits.State'])),
25-
))
26-
db.send_create_signal(u'countylimits', ['County'])
27-
28-
# Adding model 'CountyLimit'
29-
db.create_table(u'countylimits_countylimit', (
30-
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
31-
('fha_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
32-
('gse_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
33-
('va_limit', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=2)),
34-
('county', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['countylimits.County'], unique=True)),
35-
))
36-
db.send_create_signal(u'countylimits', ['CountyLimit'])
37-
38-
39-
def backwards(self, orm):
40-
# Deleting model 'State'
41-
db.delete_table(u'countylimits_state')
42-
43-
# Deleting model 'County'
44-
db.delete_table(u'countylimits_county')
45-
46-
# Deleting model 'CountyLimit'
47-
db.delete_table(u'countylimits_countylimit')
48-
49-
50-
models = {
51-
u'countylimits.county': {
52-
'Meta': {'object_name': 'County'},
53-
'county_fips': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
54-
'county_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
55-
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
56-
'state': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['countylimits.State']"})
57-
},
58-
u'countylimits.countylimit': {
59-
'Meta': {'object_name': 'CountyLimit'},
60-
'county': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['countylimits.County']", 'unique': 'True'}),
61-
'fha_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'}),
62-
'gse_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'}),
63-
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
64-
'va_limit': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '2'})
65-
},
66-
u'countylimits.state': {
67-
'Meta': {'object_name': 'State'},
68-
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
69-
'state_abbr': ('localflavor.us.models.USStateField', [], {'max_length': '2'}),
70-
'state_fips': ('django.db.models.fields.CharField', [], {'max_length': '2'})
71-
}
72-
}
73-
74-
complete_apps = ['countylimits']
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
import localflavor.us.models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='County',
16+
fields=[
17+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
18+
('county_fips', models.CharField(help_text=b"A three-digit FIPS code for the state's county", max_length=3)),
19+
('county_name', models.CharField(help_text=b'The county name', max_length=100)),
20+
],
21+
options={
22+
'ordering': ['county_fips'],
23+
},
24+
),
25+
migrations.CreateModel(
26+
name='CountyLimit',
27+
fields=[
28+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
29+
('fha_limit', models.DecimalField(help_text=b'Federal Housing Administration loan lending limit for the county', max_digits=12, decimal_places=2)),
30+
('gse_limit', models.DecimalField(help_text=b'Loan limit for mortgages acquired by the Government-Sponsored Enterprises', max_digits=12, decimal_places=2)),
31+
('va_limit', models.DecimalField(help_text=b'The Department of Veterans Affairs loan guaranty program limit', max_digits=12, decimal_places=2)),
32+
('county', models.OneToOneField(to='countylimits.County')),
33+
],
34+
),
35+
migrations.CreateModel(
36+
name='State',
37+
fields=[
38+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
39+
('state_fips', models.CharField(help_text=b'A two-digit FIPS code for the state', max_length=2)),
40+
('state_abbr', localflavor.us.models.USStateField(help_text=b'A two-letter state abbreviation', max_length=2)),
41+
],
42+
options={
43+
'ordering': ['state_fips'],
44+
},
45+
),
46+
migrations.AddField(
47+
model_name='county',
48+
name='state',
49+
field=models.ForeignKey(to='countylimits.State'),
50+
),
51+
]

docs/mysql.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pages:
33
- Introduction: index.md
44
- Usage:
55
- API endpoints: api.md
6-
- Using MySQL: mysql.md
76

87
theme: mkDOCter
98
extra:

oahapi/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
urlpatterns = [
44
url(r'^oah-api/rates/', include('ratechecker.urls')),
5-
url(r'^oah-api/county/$', include('countylimits.urls')),
5+
url(r'^oah-api/county/', include('countylimits.urls')),
66
]

pytest.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)