Commit ea0c9425 by Oleg Marshev

Add test.

parent f69981bf
import json import json
from unittest import TestCase from unittest import TestCase
from notesapi.v1.models import Note from notesapi.v1.models import Note, NoteMappingType
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
...@@ -42,7 +42,7 @@ class NoteTest(TestCase): ...@@ -42,7 +42,7 @@ class NoteTest(TestCase):
def test_must_have_fields(self): def test_must_have_fields(self):
note = Note() note = Note()
for field in ['user', 'usage_id', 'course_id']: for field in ['user', 'usage_id', 'course_id', 'ranges']:
payload = self.note.copy() payload = self.note.copy()
payload.pop(field) payload.pop(field)
...@@ -53,3 +53,9 @@ class NoteTest(TestCase): ...@@ -53,3 +53,9 @@ class NoteTest(TestCase):
note = Note() note = Note()
note.clean(self.note) note.clean(self.note)
note.save() note.save()
def test_extract_document(self):
note = Note()
note.clean(self.note)
note.save()
self.assertEqual(NoteMappingType.extract_document(note.id), note.as_dict())
...@@ -332,7 +332,7 @@ class AnnotationViewTests(BaseAnnotationViewTests): ...@@ -332,7 +332,7 @@ class AnnotationViewTests(BaseAnnotationViewTests):
Tests highlighting. Tests highlighting.
""" """
self._create_annotation(text=u'First note') self._create_annotation(text=u'First note')
note_2 = self._create_annotation(text=u'Second note') self._create_annotation(text=u'Second note')
results = self._get_search_results() results = self._get_search_results()
self.assertEqual(results['total'], 2) self.assertEqual(results['total'], 2)
......
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