Commit 76b37250 by Alex Dusenbery Committed by GitHub

Merge pull request #59 from edx/aed/django1.11

EDUCATOR-786 | Support Django 1.11
parents 3fd9244b 61a49b43
......@@ -54,3 +54,4 @@ submissions_test_db
# Sphinx documentation
docs/_build/
venvs
language: python
python:
- "2.7"
- '2.7'
env:
- TOXENV=django18
- TOXENV=django19
- TOXENV=django110
- TOXENV=django18
- TOXENV=django110
- TOXENV=django111
matrix:
allow_failures:
- env: TOXENV=django19
- env: TOXENV=django110
# Use docker for travis builds
- env: TOXENV=django110
sudo: false
install:
- "pip install -r requirements.txt"
- "pip install -r test-requirements.txt"
- "python setup.py install"
- "pip install coveralls"
- pip install -r requirements.txt
- pip install -r test-requirements.txt
- python setup.py install
- pip install coveralls
script:
- "tox"
after_success:
coveralls
- tox
after_success: coveralls
# Set password via "travis encrypt --add deploy.password"; for details, see
# https://docs.travis-ci.com/user/deployment/pypi
deploy:
provider: pypi
user: edx
distributions: sdist bdist_wheel
skip_upload_docs: true
password:
secure: BlYK3lplRoPiNfzqslxyReJZrC1QUT9Ls1A1xIxc3IHxKl9WEkqC2xO5vBvQDFKtMyooq8bGeN/gfksaZpRYqBmrO7hPITiz0FH0wPFdjoIikI4NTqKVxjhqUho0ZWmpxNXrX/iMd9Y2R4uZRXZGaWaTSRHfF9fPVlkbo66s7vw=
tags: true
......@@ -36,7 +36,8 @@ To run the test suite:
.. code:: bash
python manage.py test
pip install -r test-requirements.txt
tox # to run only a single environment, do e.g. tox -e django18
License
......
......@@ -10,11 +10,12 @@ DATABASES = {
'ENGINE': 'django.db.backends.sqlite3',
'TEST_NAME': 'submissions_test_db',
},
'read_replica': {
'ENGINE': 'django.db.backends.sqlite3',
'TEST_MIRROR': 'default'
}
'TEST': {
'MIRROR': 'default',
},
},
}
CACHES = {
......
......@@ -33,7 +33,7 @@ def load_requirements(*requirements_paths):
setup(
name='edx-submissions',
version='2.0.1',
version='2.0.2',
author='edX',
description='An API for creating submissions and scores.',
url='http://github.com/edx/edx-submissions.git',
......
......@@ -2,13 +2,27 @@
Test API calls using the read replica.
"""
import copy
from django.conf import settings
from django.test import TransactionTestCase
import mock
from submissions import api as sub_api
def _mock_use_read_replica(queryset):
"""
The Django DATABASES setting TEST_MIRROR isn't reliable.
See: https://code.djangoproject.com/ticket/23718
"""
return (
queryset.using('default')
if 'read_replica' in settings.DATABASES
else queryset
)
class ReadReplicaTest(TransactionTestCase):
""" Test queries that use the read replica. """
STUDENT_ITEM = {
"student_id": "test student",
"course_id": "test course",
......@@ -31,15 +45,17 @@ class ReadReplicaTest(TransactionTestCase):
)
def test_get_submission_and_student(self):
retrieved = sub_api.get_submission_and_student(self.submission['uuid'], read_replica=True)
expected = copy.deepcopy(self.submission)
expected['student_item'] = copy.deepcopy(self.STUDENT_ITEM)
self.assertEqual(retrieved, expected)
with mock.patch('submissions.api._use_read_replica', _mock_use_read_replica):
retrieved = sub_api.get_submission_and_student(self.submission['uuid'], read_replica=True)
expected = copy.deepcopy(self.submission)
expected['student_item'] = copy.deepcopy(self.STUDENT_ITEM)
self.assertEqual(retrieved, expected)
def test_get_latest_score_for_submission(self):
retrieved = sub_api.get_latest_score_for_submission(self.submission['uuid'], read_replica=True)
self.assertEqual(retrieved['points_possible'], self.SCORE['points_possible'])
self.assertEqual(retrieved['points_earned'], self.SCORE['points_earned'])
with mock.patch('submissions.api._use_read_replica', _mock_use_read_replica):
retrieved = sub_api.get_latest_score_for_submission(self.submission['uuid'], read_replica=True)
self.assertEqual(retrieved['points_possible'], self.SCORE['points_possible'])
self.assertEqual(retrieved['points_earned'], self.SCORE['points_earned'])
def test_get_top_submissions(self):
student_item_1 = copy.deepcopy(self.STUDENT_ITEM)
......@@ -60,7 +76,7 @@ class ReadReplicaTest(TransactionTestCase):
sub_api.set_score(student_3['uuid'], 2, 10)
# Use the read-replica
with self.assertNumQueries(0):
with mock.patch('submissions.api._use_read_replica', _mock_use_read_replica):
top_scores = sub_api.get_top_submissions(
self.STUDENT_ITEM['course_id'],
self.STUDENT_ITEM['item_id'],
......@@ -79,4 +95,4 @@ class ReadReplicaTest(TransactionTestCase):
'score': 4
},
]
)
\ No newline at end of file
)
ddt==0.8.0
django-nose==1.4.1
django-nose==1.4.4
freezegun==0.1.11
mock==1.0.1
nose==1.3.3
......@@ -16,4 +16,4 @@ sphinx-rtd-theme==0.1.5
sphinxcontrib-napoleon==0.2.3
# Tox
tox==2.6.0
tox==2.7.0
[tox]
envlist = django{18,19,110}
envlist = django{18,110,111}
[testenv]
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
commands =
python manage.py test
python setup.py build_sphinx
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment