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.

30 lines
1.3 KiB

  1. from django.test import TestCase
  2. from model_mommy import mommy
  3. from data_export.models import ExportedExample
  4. from projects.tests.utils import prepare_project
  5. class TestExportedExample(TestCase):
  6. def prepare_data(self, collaborative=False):
  7. self.project = prepare_project(collaborative_annotation=collaborative)
  8. self.example1 = mommy.make("ExportedExample", project=self.project.item)
  9. self.example2 = mommy.make("ExportedExample", project=self.project.item)
  10. mommy.make("ExampleState", example=self.example1, confirmed_by=self.project.admin)
  11. def test_collaborative(self):
  12. self.prepare_data(collaborative=True)
  13. examples = ExportedExample.objects.confirmed(self.project.item)
  14. self.assertEqual(examples.count(), 1)
  15. self.assertEqual(examples.first(), self.example1)
  16. def test_filter_by_confirmed_user(self):
  17. self.prepare_data(collaborative=False)
  18. examples = ExportedExample.objects.confirmed(self.project.item, user=self.project.admin)
  19. self.assertEqual(examples.count(), 1)
  20. self.assertEqual(examples.first(), self.example1)
  21. def test_filter_by_unconfirmed_user(self):
  22. self.prepare_data(collaborative=False)
  23. examples = ExportedExample.objects.confirmed(self.project.item, user=self.project.annotator)
  24. self.assertEqual(examples.count(), 0)