cfpb / college-costs

⚠️ Deprecated: see note. ⚠️ A tool to help students weigh the costs and rewards of a college program.
https://www.consumerfinance.gov/paying-for-college2/understanding-your-financial-aid-offer/about-this-tool/
50 stars 27 forks source link

Update PFC to use djangorestframework 3.1.3 #287

Closed higs4281 closed 8 years ago

higs4281 commented 8 years ago

This PR supports cfgov-refresh PR 2456

Changes

python manage.py loaddata collegedata
python manage.py load_programs --s3 true http://files.consumerfinance.gov.s3.amazonaws.com/pb/paying_for_college/csv/argosySF_test_program.csv

This loads a test program row in your local db. The first time you run it, you should get back:

1 programs created. 0 programs updated.

Review

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling bfb47e79e2f0a63f30e20eb80f467dda0db17787 on DRF-upgrade into a6cdd86949372fcecb320828518cd5c55603b964 on master.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 53f7d0db8342c80f6492db443641252e1920e6c9 on DRF-upgrade into a6cdd86949372fcecb320828518cd5c55603b964 on master.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3244ce2bdcb241fc76d115730a81fc44a17162d2 on DRF-upgrade into a6cdd86949372fcecb320828518cd5c55603b964 on master.

chosak commented 8 years ago

If I first create a new local database (by running manage.py migrate) and then run the tests using ./pytest.sh, I get a test error, but then the overall command succeeds with error code 0:

(college-costs) ~/Projects/college-costs DRF-upgrade $ ./pytest.sh 
..............................................................................................................E..
======================================================================
ERROR: paying_for_college.tests.test_search_index (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: paying_for_college.tests.test_search_index
Traceback (most recent call last):
  File "/Users/chosaka/homebrew/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 254, in _find_tests
    module = self._get_module_from_name(name)
  File "/Users/chosaka/homebrew/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/Users/chosaka/Projects/college-costs/paying_for_college/tests/test_search_index.py", line 10, in <module>
    class SchoolIndexTest(TestCase):
  File "/Users/chosaka/Projects/college-costs/paying_for_college/tests/test_search_index.py", line 14, in SchoolIndexTest
    mock_obj = School.objects.get(pk=155317)
  File "/Users/chosaka/.virtualenvs/college-costs/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/chosaka/.virtualenvs/college-costs/lib/python2.7/site-packages/django/db/models/query.py", line 334, in get
    self.model._meta.object_name
DoesNotExist: School matching query does not exist.

----------------------------------------------------------------------
Ran 113 tests in 6.814s

FAILED (errors=1)

... (stripped coverage output)

(college-costs) ~/Projects/college-costs DRF-upgrade $ echo $?
0

Similarly, the load_programs command gives me this error:

(college-costs) ~/Projects/college-costs DRF-upgrade $ python manage.py load_programs --s3 true http://files.consumerfinance.gov.s3.amazonaws.com/pb/paying_for_college/csv/argosySF_test_program.csv
ERROR: couldn't find school for ID 121983
0 programs created. 0 programs updated.

Am I missing a step somewhere?

higs4281 commented 8 years ago

@chosak

Re testing the script: Try loading the collegedata fixture first (I updated test instructions).

python manage.py loaddata collegedata
chosak commented 8 years ago

@higs4281 thanks, both commands work for me now. 👍

How would you feel about adding

set -e

to the top of pytest.sh script so that it fails if any of the tests fail?

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 0bdb5fc0457faa63e53d8b423e20ce7dc8709c11 on DRF-upgrade into a6cdd86949372fcecb320828518cd5c55603b964 on master.