You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. from django.test import TestCase
  2. from django.core.exceptions import ValidationError
  3. from django.db.utils import IntegrityError
  4. from mixer.backend.django import mixer
  5. class TestProject(TestCase):
  6. def test_project_type(self):
  7. project = mixer.blend('server.Project')
  8. project.is_type_of(project.project_type)
  9. class TestLabel(TestCase):
  10. def test_shortcut_uniqueness(self):
  11. label = mixer.blend('server.Label')
  12. with self.assertRaises(IntegrityError):
  13. mixer.blend('server.Label',
  14. shortcut=label.shortcut)
  15. def test_text_uniqueness(self):
  16. label = mixer.blend('server.Label')
  17. with self.assertRaises(IntegrityError):
  18. mixer.blend('server.Label',
  19. text=label.text)
  20. class TestDocumentAnnotation(TestCase):
  21. def test_uniqueness(self):
  22. annotation1 = mixer.blend('server.DocumentAnnotation')
  23. with self.assertRaises(IntegrityError):
  24. mixer.blend('server.DocumentAnnotation',
  25. document=annotation1.document,
  26. user=annotation1.user,
  27. label=annotation1.label)
  28. class TestSequenceAnnotation(TestCase):
  29. def test_uniqueness(self):
  30. annotation1 = mixer.blend('server.SequenceAnnotation')
  31. with self.assertRaises(IntegrityError):
  32. mixer.blend('server.SequenceAnnotation',
  33. document=annotation1.document,
  34. user=annotation1.user,
  35. label=annotation1.label,
  36. start_offset=annotation1.start_offset,
  37. end_offset=annotation1.end_offset)
  38. def test_position_constraint(self):
  39. with self.assertRaises(ValidationError):
  40. mixer.blend('server.SequenceAnnotation',
  41. start_offset=1, end_offset=0).clean()
  42. class TestSeq2seqAnnotation(TestCase):
  43. def test_uniqueness(self):
  44. annotation1 = mixer.blend('server.Seq2seqAnnotation')
  45. with self.assertRaises(IntegrityError):
  46. mixer.blend('server.Seq2seqAnnotation',
  47. document=annotation1.document,
  48. user=annotation1.user,
  49. text=annotation1.text)