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.

25 lines
799 B

  1. import uuid
  2. from django.test import TestCase
  3. from data_import.pipeline.examples import Examples
  4. from examples.models import Example
  5. from projects.models import DOCUMENT_CLASSIFICATION
  6. from projects.tests.utils import prepare_project
  7. class TestExamples(TestCase):
  8. def setUp(self):
  9. self.project = prepare_project(DOCUMENT_CLASSIFICATION)
  10. self.example_uuid = uuid.uuid4()
  11. example = Example(uuid=self.example_uuid, text="A", project=self.project.item)
  12. self.examples = Examples([example])
  13. def test_save(self):
  14. self.examples.save()
  15. self.assertEqual(Example.objects.count(), 1)
  16. def test_getitem(self):
  17. self.examples.save()
  18. example = self.examples[self.example_uuid]
  19. self.assertEqual(example.uuid, self.example_uuid)