-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade to Django 1.8 and DRF 3.x
This doc is meant to help someone get involved with our upgrade to Django 1.8 and Django Rest Framework 3.x. Feel free to reach out, report an issue, or contribute to this wiki if you have any questions!
Make sure that your environment is properly set up. Here are some tips for doing this:
- check out the development branch that you want to help with. For example, you can check out the
django18
branch. - don't forget to reinstall the requirements! Using virtualenvwrapper, it would be something like this:
mkvirtualenv --python=python2.7 smartercleanup-api-django18
, thenpip install -r requirements.txt
. - run the migrations via
./manage.py migrate
to run the database migrations. You can view your current state of migrations via./manage.py showmigrations
. Note thatshowmigrations
is a command specific to Django 1.8. You can show migrations in Django 1.7 with./manage.py migrate --list
. - run the tests via
./manage.py test
.
You should be able to run ./manage.py test
in the project's /src
directory, and all 170 tests pass should be passing on the master
branch.
Our goal is to basically fix our unit tests using the latest Django 1.8 and DRF 3.x libraries. Once our unit tests are fixed, the job should be done!
Here is the status of the unit tests on our development branches:
django18-drf3
branch
Running all tests should have the following results, with the command ./manage.py test
:
Ran 170 tests in 19.904s
FAILED (errors=25, failures=49)
and running only the tests on our views should produce the following results with the command ./manage.py test sa_api_v2.tests.test_views
:
Ran 93 tests in 17.916s
FAILED (errors=24, failures=48)
and here we run all tests on our TestPlaceInstanceView
view, with the command ./manage.py test sa_api_v2.tests.test_views:TestPlaceInstanceView
:
Ran 17 tests in 4.998s
FAILED (errors=1, failures=4)
You should have the same number of error/failures. Note that these rates will go down as we fix more tests!
To run a specific unit test, in a specific class, you can use the nose test syntax for Django, as shown here: ./manage.py test sa_api_v2.tests.test_views:TestPlaceInstanceView.test_GET_response
Sometimes the output can be very lengthy, and you can pipe that into a file, which will make it easier to review by opening up the file in your text editor. This is how you pipe the output into a file:./manage.py test sa_api_v2.tests.test_views:TestPlaceInstanceView.test_GET_response2>&1 | tee test-output.txt
Then you can look into test-output.txt
for the error log output.
We are upgrading the Django Rest Framework from 2.4 to 3.x. The following docs are helpful when porting our codebase to the newer framework:
- DRF 3.x: http://www.django-rest-framework.org/
- DRF 2.x: http://www.tomchristie.com/rest-framework-2-docs/
Our branch that is addressing the upgrade to DRF 3.x is on django18-drf3
, and is based off of our django18
branch.