Closed higs4281 closed 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?
@chosak
Re testing the script: Try loading the collegedata fixture first (I updated test instructions).
python manage.py loaddata collegedata
@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?
This PR supports cfgov-refresh PR 2456
Changes
Testing
./pytest.sh
This loads a test program row in your local db. The first time you run it, you should get back:
Review