Commit 86e209ae by Eric Fischer Committed by GitHub

Merge pull request #65 from edx/efischer/loosen_reqs

Clean up requirements, remove django_extensions
parents e57b6755 bbf9b618
dogapi==1.2.1
django-extensions==1.5.9
django-model-utils==2.3.1
dogapi>=1.2.1,<2.0.0
django-model-utils>=2.3.1,<3.0.0
# Use the same DRF version as edx-platform
git+https://github.com/edx/django-rest-framework.git@1ceda7c086fddffd1c440cc86856441bbf0bd9cb#egg=djangorestframework==3.6.3
jsonfield==1.0.3
jsonfield>=1.0.3,<2.0.0
pytz
......@@ -52,9 +52,6 @@ INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
# Third party
'django_extensions',
# Test
'django_nose',
......
......@@ -33,7 +33,7 @@ def load_requirements(*requirements_paths):
setup(
name='edx-submissions',
version='2.0.5',
version='2.0.6',
author='edX',
description='An API for creating submissions and scores.',
url='http://github.com/edx/edx-submissions.git',
......
......@@ -7,6 +7,7 @@ import itertools
import logging
import operator
import json
from uuid import UUID
from django.conf import settings
from django.core.cache import cache
......@@ -222,8 +223,11 @@ def get_submission(submission_uuid, read_replica=False):
"""
if not isinstance(submission_uuid, basestring):
if isinstance(submission_uuid, UUID):
submission_uuid = unicode(submission_uuid)
else:
raise SubmissionRequestError(
msg="submission_uuid ({!r}) must be a string type".format(submission_uuid)
msg="submission_uuid ({!r}) must be serializable".format(submission_uuid)
)
cache_key = Submission.get_cache_key(submission_uuid)
......
......@@ -4,7 +4,6 @@ from __future__ import unicode_literals
from django.db import migrations, models
import jsonfield.fields
import django.utils.timezone
import django_extensions.db.fields
class Migration(migrations.Migration):
......@@ -48,7 +47,7 @@ class Migration(migrations.Migration):
name='Submission',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('uuid', django_extensions.db.fields.UUIDField(db_index=True, version=1, editable=False, blank=True)),
('uuid', models.UUIDField(db_index=True, editable=False, blank=True)),
('attempt_number', models.PositiveIntegerField()),
('submitted_at', models.DateTimeField(default=django.utils.timezone.now, db_index=True)),
('created_at', models.DateTimeField(default=django.utils.timezone.now, editable=False, db_index=True)),
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('submissions', '0003_submission_status'),
]
operations = [
migrations.AlterField(
model_name='submission',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, db_index=True),
),
]
......@@ -10,12 +10,12 @@ need to then generate a matching migration for it using:
"""
import logging
from uuid import uuid4
from django.db import models, DatabaseError
from django.db.models.signals import post_save
from django.dispatch import receiver, Signal
from django.utils.timezone import now
from django_extensions.db.fields import UUIDField
from jsonfield import JSONField
......@@ -101,7 +101,7 @@ class Submission(models.Model):
"""
MAXSIZE = 1024*100 # 100KB
uuid = UUIDField(version=1, db_index=True)
uuid = models.UUIDField(db_index=True, default=uuid4)
student_item = models.ForeignKey(StudentItem)
......@@ -196,7 +196,7 @@ class Score(models.Model):
"""
if self.submission is not None:
return self.submission.uuid
return unicode(self.submission.uuid)
else:
return None
......
......@@ -48,6 +48,7 @@ class TestSubmissionsApi(TestCase):
"""
Clear the cache.
"""
super(TestSubmissionsApi, self).setUp()
cache.clear()
@ddt.data(ANSWER_ONE, ANSWER_DICT)
......@@ -67,10 +68,14 @@ class TestSubmissionsApi(TestCase):
retrieved = api.get_submission_and_student(submission['uuid'])
self.assertItemsEqual(submission, retrieved)
# Should raise an exception if the student item does not exist
with self.assertRaises(api.SubmissionNotFoundError):
# Should raise an exception if uuid is malformed
with self.assertRaises(api.SubmissionInternalError):
api.get_submission_and_student(u'no such uuid')
# Should raise a different exception if the student item does not exist
with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission_and_student(u'deadbeef-1234-5678-9100-1234deadbeef')
def test_get_submissions(self):
api.create_submission(STUDENT_ITEM, ANSWER_ONE)
api.create_submission(STUDENT_ITEM, ANSWER_TWO)
......@@ -161,9 +166,7 @@ class TestSubmissionsApi(TestCase):
# Test not found
with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission("notarealuuid")
with self.assertRaises(api.SubmissionNotFoundError):
api.get_submission("0" * 50) # This is bigger than our field size
api.get_submission("deadbeef-1234-5678-9100-1234deadbeef")
@patch.object(Submission.objects, 'get')
@raises(api.SubmissionInternalError)
......
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