Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • arkindex/backend
1 result
Show changes
Showing
with 726 additions and 675 deletions
......@@ -48,8 +48,6 @@ class TestLoadExport(FixtureTestCase):
"documents.elementpath": [],
"documents.entity": [],
"documents.entitytype": [],
"documents.entityrole": [],
"documents.entitylink": [],
"documents.transcription": [],
"documents.transcriptionentity": [],
"documents.metadata": ["index"],
......@@ -162,13 +160,6 @@ class TestLoadExport(FixtureTestCase):
validated=True,
moderator=self.superuser,
)
role = self.corpus.roles.create(
parent_name="parent",
child_name="child",
parent_type=location_type,
child_type=person_type,
)
role.links.create(parent=entity1, child=entity2)
transcription.transcription_entities.create(
entity=entity1,
......@@ -251,7 +242,6 @@ class TestLoadExport(FixtureTestCase):
self.assertEqual(corpus.ml_classes.all().count(), 0)
self.assertEqual(corpus.elements.all().count(), 0)
self.assertEqual(corpus.entities.all().count(), 0)
self.assertEqual(corpus.roles.all().count(), 0)
@patch("arkindex.documents.export.os.unlink")
@patch("arkindex.project.aws.s3.Object")
......@@ -273,10 +263,6 @@ class TestLoadExport(FixtureTestCase):
dataset_set = Dataset.objects.first().sets.first()
DatasetElement.objects.create(set=dataset_set, element=element)
person_type = EntityType.objects.get(
name="person",
corpus=self.corpus
)
location_type = EntityType.objects.get(
name="location",
corpus=self.corpus
......@@ -286,19 +272,6 @@ class TestLoadExport(FixtureTestCase):
name="Arrokuda",
type=location_type,
)
entity2 = self.corpus.entities.create(
name="Stonjourner",
type=person_type,
validated=True,
moderator=self.superuser,
)
role = self.corpus.roles.create(
parent_name="parent",
child_name="child",
parent_type=location_type,
child_type=person_type,
)
role.links.create(parent=entity1, child=entity2)
transcription.transcription_entities.create(
entity=entity1,
......@@ -329,7 +302,6 @@ class TestLoadExport(FixtureTestCase):
self.assertEqual(corpus.ml_classes.all().count(), 1)
self.assertEqual(corpus.elements.all().count(), 0)
self.assertEqual(corpus.entities.all().count(), 0)
self.assertEqual(corpus.roles.all().count(), 0)
def test_create_worker(self):
repo_uuid = Repository.objects.get(url="http://my_repo.fake/workers/worker").id
......
......@@ -72,20 +72,6 @@ class TestMergeEntities(FixtureTestCase):
element.metadatas.create(type=MetaType.Text, name="something", value="dupe", entity=entity1)
element.metadatas.create(type=MetaType.Text, name="something", value="dupe", entity=entity2)
role = self.corpus.roles.create(
parent_type=self.person_type,
child_type=self.person_type,
parent_name="parent",
child_name="child",
)
# entity1 and entity2 are duplicates, so the deduplication would cause those links to be duplicates,
# but there are no constraints at all on EntityLinks, so there will not be any deletions.
role.links.create(parent=entity1, child=unique_entity)
role.links.create(parent=entity2, child=unique_entity)
# Nothing will stop an entity from being linked to itself either.
role.links.create(parent=entity1, child=entity2)
transcription = element.transcriptions.get()
worker_version = WorkerVersion.objects.first()
worker_run = WorkerRun.objects.first()
......@@ -158,10 +144,6 @@ class TestMergeEntities(FixtureTestCase):
Deleted 1 TranscriptionEntities.
Updating entity IDs on TranscriptionEntities…
Updated 1 TranscriptionEntities.
Updating child entity IDs on entity links…
Updated 1 entity links.
Updating parent entity IDs on entity links…
Updated 1 entity links.
Removing duplicate entities…
Removed 1 duplicate entities from corpus Unit Tests.
""").strip()
......@@ -195,24 +177,6 @@ class TestMergeEntities(FixtureTestCase):
]
)
self.assertListEqual(
list(role.links.order_by("parent_id", "child_id").values("parent_id", "child_id")),
[
{
"parent_id": entity1.id,
"child_id": entity1.id,
},
{
"parent_id": entity1.id,
"child_id": unique_entity.id,
},
{
"parent_id": entity1.id,
"child_id": unique_entity.id,
},
]
)
self.assertListEqual(
list(transcription.transcription_entities.order_by("id").values("entity_id", "offset", "length", "worker_version_id", "worker_run_id")),
[
......
......@@ -89,22 +89,6 @@ class TestDeleteCorpus(FixtureTestCase):
person_type = EntityType.objects.get(name="person", corpus=cls.corpus)
entity1 = cls.corpus.entities.create(name="Magnemite", type=person_type)
entity2 = cls.corpus.entities.create(
name="Magneton",
type=person_type,
worker_version=cls.worker_version,
worker_run=worker_run,
)
role = cls.corpus.roles.create(
parent_name="origin",
child_name="evolution",
parent_type=person_type,
child_type=person_type,
)
# Note: .parents means the EntityLinks where this entity is the parent,
# so they actually are the entity's children, and .children maps to the links to the entity's parents!
entity1.parents.create(child=entity2, role=role)
Transcription.objects.filter(element__corpus=cls.corpus).first().transcription_entities.create(
entity=entity1,
......
......@@ -14,7 +14,6 @@ from arkindex.documents.models import (
Classification,
CorpusExportState,
ElementPath,
EntityLink,
EntityType,
MetaData,
MetaType,
......@@ -32,8 +31,6 @@ TABLE_NAMES = {
"element",
"element_path",
"entity",
"entity_link",
"entity_role",
"entity_type",
"image",
"image_server",
......@@ -108,13 +105,6 @@ class TestExport(FixtureTestCase):
validated=True,
moderator=self.superuser,
)
role = self.corpus.roles.create(
parent_name="parent",
child_name="child",
parent_type=location_type,
child_type=person_type,
)
role.links.create(parent=entity1, child=entity2)
transcription.transcription_entities.create(
entity=entity1,
......@@ -169,7 +159,7 @@ class TestExport(FixtureTestCase):
)
self.assertCountEqual(
db.execute("SELECT version FROM export_version").fetchall(), [(8, )]
db.execute("SELECT version FROM export_version").fetchall(), [(9, )]
)
self.assertCountEqual(
......@@ -423,33 +413,6 @@ class TestExport(FixtureTestCase):
]
)
self.assertCountEqual(
db.execute("SELECT id, parent_name, child_name, parent_type_id, child_type_id FROM entity_role").fetchall(),
[
(
str(role.id),
role.parent_name,
role.child_name,
str(role.parent_type.id),
str(role.child_type.id),
)
for role in self.corpus.roles.all()
]
)
self.assertCountEqual(
db.execute("SELECT id, parent_id, child_id, role_id FROM entity_link").fetchall(),
[
(
str(link.id),
str(link.parent_id),
str(link.child_id),
str(link.role_id)
)
for link in EntityLink.objects.filter(role__corpus=self.corpus)
]
)
self.assertCountEqual(
db.execute("""
SELECT
......
......@@ -74,7 +74,6 @@ class TestCorpus(FixtureAPITestCase):
mock_now.return_value = FAKE_NOW
cls.corpus_hidden = Corpus.objects.create(name="C Hidden")
@expectedFailure
def test_anon(self):
# An anonymous user has only access to public
with self.assertNumQueries(4):
......@@ -225,7 +224,6 @@ class TestCorpus(FixtureAPITestCase):
self.assertEqual(len(data), 13)
self.assertSetEqual({corpus["top_level_type"] for corpus in data}, {None, "top_level"})
@expectedFailure
def test_mixin(self):
vol1 = Element.objects.get(name="Volume 1")
vol2 = Element.objects.get(name="Volume 2")
......@@ -345,7 +343,7 @@ class TestCorpus(FixtureAPITestCase):
"description": self.corpus_public.description,
"public": True,
"indexable": False,
"rights": ["read", "write", "admin"],
"rights": ["read"],
"created": DB_CREATED,
"authorized_users": 1,
"top_level_type": None,
......
from django.core.exceptions import ValidationError
from arkindex.documents.models import Corpus, Entity, EntityLink, EntityRole, EntityType, MetaData, MetaType
from arkindex.documents.models import Corpus, Entity, EntityType, MetaData, MetaType
from arkindex.process.models import WorkerVersion
from arkindex.project.tests import FixtureTestCase
......@@ -33,46 +33,6 @@ class TestSaveEntities(FixtureTestCase):
name="child",
worker_version=worker_version,
)
cls.role = EntityRole.objects.create(
parent_name="organization",
child_name="person",
parent_type=cls.org_type,
child_type=cls.person_type,
corpus=cls.corpus1,
)
cls.link = EntityLink(parent=cls.parent, child=cls.child, role=cls.role)
def test_parent_type_different(self):
self.parent.corpus = self.corpus1
self.child.corpus = self.corpus1
self.parent.type = self.person_type
self.child.type = self.person_type
with self.assertRaises(ValidationError):
self.link.save()
def test_parent_corpus_different(self):
self.parent.corpus = self.corpus2
self.child.corpus = self.corpus1
self.parent.type = self.org_type
self.child.type = self.person_type
with self.assertRaises(ValidationError):
self.link.save()
def test_child_type_different(self):
self.parent.corpus = self.corpus1
self.child.corpus = self.corpus1
self.parent.type = self.org_type
self.child.type = self.org_type
with self.assertRaises(ValidationError):
self.link.save()
def test_child_corpus_different(self):
self.parent.corpus = self.corpus1
self.child.corpus = self.corpus2
self.parent.type = self.org_type
self.child.type = self.person_type
with self.assertRaises(ValidationError):
self.link.save()
def test_save_entity_in_metadata(self):
self.parent.corpus = self.corpus2
......
......@@ -3,7 +3,7 @@ from unittest.mock import call, patch
from django.urls import reverse
from rest_framework import status
from arkindex.documents.models import Corpus, Entity, EntityRole, EntityType
from arkindex.documents.models import Corpus, Entity, EntityType
from arkindex.project.tests import FixtureAPITestCase
from arkindex.users.models import Role, User
......@@ -397,7 +397,7 @@ class TestEntityTypesAPI(FixtureAPITestCase):
def test_delete(self):
self.client.force_login(self.private_corpus_admin)
with self.assertNumQueries(7):
with self.assertNumQueries(6):
response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
with self.assertRaises(EntityType.DoesNotExist):
......@@ -411,20 +411,6 @@ class TestEntityTypesAPI(FixtureAPITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertDictEqual(response.json(), {"detail": ["Some entities are using this entity type."]})
def test_delete_has_roles(self):
EntityRole.objects.create(
corpus=self.private_corpus,
parent_name="goose",
child_name="rooster",
parent_type=self.private_corpus_entity_type,
child_type=self.private_corpus_entity_type
)
self.client.force_login(self.private_corpus_admin)
with self.assertNumQueries(6):
response = self.client.delete(reverse("api:entity-type-details", kwargs={"pk": self.private_corpus_entity_type.id}), format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertDictEqual(response.json(), {"detail": ["Some entity roles are using this entity type."]})
# LIST CORPUS ENTITY TYPES
def test_list_does_not_require_login_public_project(self):
......
......@@ -43,7 +43,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"public": True,
},
"thumbnail_url": self.vol.thumbnail.s3_url,
"thumbnail_put_url": self.vol.thumbnail.s3_put_url,
"thumbnail_put_url": None,
"worker_version": None,
"confidence": None,
"zone": None,
......@@ -51,7 +51,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"mirrored": False,
"created": "2020-02-02T01:23:45.678000Z",
"creator": None,
"rights": ["read", "write", "admin"],
"rights": ["read"],
"metadata_count": 0,
"classifications": [
{
......@@ -102,6 +102,8 @@ class TestRetrieveElements(FixtureAPITestCase):
"""
Check getting an element only gives a thumbnail URL with folders
"""
self.client.force_login(self.user)
self.assertTrue(self.vol.type.folder)
response = self.client.get(reverse("api:element-retrieve", kwargs={"pk": str(self.vol.id)}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
......@@ -230,7 +232,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"public": True,
},
"thumbnail_url": self.vol.thumbnail.s3_url,
"thumbnail_put_url": self.vol.thumbnail.s3_put_url,
"thumbnail_put_url": None,
"worker_version": str(self.worker_version.id),
"confidence": None,
"zone": None,
......@@ -238,7 +240,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"mirrored": False,
"created": "2020-02-02T01:23:45.678000Z",
"creator": None,
"rights": ["read", "write", "admin"],
"rights": ["read"],
"metadata_count": 0,
"classifications": [],
"worker_run": {
......@@ -265,7 +267,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"public": True,
},
"thumbnail_url": self.vol.thumbnail.s3_url,
"thumbnail_put_url": self.vol.thumbnail.s3_put_url,
"thumbnail_put_url": None,
"worker_version": None,
"confidence": None,
"zone": None,
......@@ -273,7 +275,7 @@ class TestRetrieveElements(FixtureAPITestCase):
"mirrored": False,
"created": "2020-02-02T01:23:45.678000Z",
"creator": None,
"rights": ["read", "write", "admin"],
"rights": ["read"],
"metadata_count": 0,
"classifications": [
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.