Skip to content

Commit

Permalink
Merge pull request #79 from Leibniz-HBI/mr-delete-origin
Browse files Browse the repository at this point in the history
Mr delete origin
  • Loading branch information
mo-fu authored Feb 21, 2024
2 parents 5382b87 + 8a800ce commit e88e805
Show file tree
Hide file tree
Showing 104 changed files with 3,154 additions and 2,525 deletions.
23 changes: 18 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from vran.entity.models_django import Entity
from vran.management.display_txt.util import DISPLAY_TXT_ORDER_CONFIG_KEY
from vran.management.models_django import ConfigValue
from vran.tag.models_django import TagDefinition
from vran.tag.models_django import TagDefinition, TagDefinitionHistory
from vran.util import VranUser


Expand Down Expand Up @@ -63,8 +63,8 @@ def entity2():

@pytest.fixture()
def tag_def(user):
return TagDefinition.objects.create( # pylint: disable=no-member
id_persistent=ct.id_tag_persistent_test,
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
id_persistent=ct.id_tag_def_persistent_test,
name=ct.name_tag_def_test,
time_edit=ct.time_edit_test,
type=TagDefinition.STRING,
Expand All @@ -73,9 +73,22 @@ def tag_def(user):
)


@pytest.fixture()
def tag_def_disabled(user):
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
id_persistent=ct.id_tag_def_disabled_test,
name=ct.name_tag_def_disabled_test,
time_edit=ct.time_edit_test,
type=TagDefinition.STRING,
owner=user,
curated=False,
disabled=True,
)


@pytest.fixture()
def tag_def1(user1):
return TagDefinition.objects.create( # pylint: disable=no-member
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
id_persistent=ct.id_tag_def_persistent_test_user1,
name=ct.name_tag_def_test1,
time_edit=ct.time_edit_test1,
Expand All @@ -87,7 +100,7 @@ def tag_def1(user1):

@pytest.fixture()
def tag_def_curated():
return TagDefinition.objects.create( # pylint: disable=no-member
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
id_persistent=ct.id_tag_def_curated_test,
name=ct.name_tag_def_curated_test,
time_edit=ct.time_edit_curated_test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_get_with_match_tag_definition_list(auth_server, tag_def1, tag_def_curat
"name_path": [tag_def_curated.name],
"type": "STRING",
"hidden": tag_def_curated.hidden,
"disabled": tag_def_curated.disabled,
"owner": None,
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tests.user.common as cu
from vran.contribution.models_django import ContributionCandidate
from vran.contribution.tag_definition.models_django import TagDefinitionContribution
from vran.tag.models_django import TagDefinition
from vran.tag.models_django import TagDefinition, TagDefinitionHistory
from vran.util.auth import NotAuthenticatedException, VranUser


Expand Down Expand Up @@ -203,7 +203,7 @@ def test_complete_assignment(auth_server):
)
)
id_tag_definition_persistent = str(uuid4())
TagDefinition.objects.create( # pylint: disable=no-member
TagDefinitionHistory.objects.create( # pylint: disable=no-member
name="tag definition_test",
id_parent_persistent=None,
type=TagDefinition.INNER,
Expand Down
11 changes: 8 additions & 3 deletions tests/contribution/entity/queue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
from vran.contribution.entity.models_django import EntityDuplicate
from vran.contribution.models_django import ContributionCandidate
from vran.entity.models_django import Entity
from vran.tag.models_django import TagDefinition, TagInstance, TagInstanceHistory
from vran.tag.models_django import (
TagDefinition,
TagDefinitionHistory,
TagInstance,
TagInstanceHistory,
)


@pytest.fixture()
Expand Down Expand Up @@ -66,7 +71,7 @@ def test_removes_contribution_candidate_from_others(entity_duplicate):

@pytest.fixture
def tag_def(user):
return TagDefinition.objects.create( # pylint: disable = no-member
return TagDefinitionHistory.objects.create( # pylint: disable = no-member
id_persistent=c.id_tag_def_test,
name=c.name_tag_def_test,
type=TagDefinition.STRING,
Expand All @@ -77,7 +82,7 @@ def tag_def(user):

@pytest.fixture
def tag_def1(user):
return TagDefinition.objects.create( # pylint: disable = no-member
return TagDefinitionHistory.objects.create( # pylint: disable = no-member
id_persistent=c.id_tag_def_test1,
id_parent_persistent=c.id_tag_def_test,
name=c.name_tag_def_test1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tests.contribution.tag_definition.api.integration.requests as req
from vran.contribution.models_django import ContributionCandidate
from vran.contribution.tag_definition.models_django import TagDefinitionContribution
from vran.tag.models_django import TagDefinition
from vran.tag.models_django import TagDefinition, TagDefinitionHistory
from vran.util.auth import NotAuthenticatedException


Expand Down Expand Up @@ -203,7 +203,7 @@ def test_patch_id_existing(auth_server):
server, cookies
)
new_id_existing = str(uuid4)
TagDefinition.objects.create(
TagDefinitionHistory.objects.create(
name="existing tag def test",
type=TagDefinition.INNER,
id_persistent=new_id_existing,
Expand Down
6 changes: 3 additions & 3 deletions tests/contribution/tag_definition/queue/ingest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from vran.contribution.tag_definition.queue.ingest import ingest_values_from_csv
from vran.entity.models_django import Entity
from vran.merge_request.models_django import TagMergeRequest
from vran.tag.models_django import TagDefinition, TagInstance
from vran.tag.models_django import TagDefinition, TagDefinitionHistory, TagInstance

csv_cols = {
"names": ["name_0", "name_1"],
Expand Down Expand Up @@ -47,7 +47,7 @@ def csv_mock_with_empty_lines():

@pytest.fixture
def verified_tag_def(db):
return TagDefinition.objects.create( # pylint: disable=no-member
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
name="tag definition verified_test",
id_parent_persistent=None,
type=TagDefinition.INNER,
Expand All @@ -58,7 +58,7 @@ def verified_tag_def(db):

@pytest.fixture
def party_tag_def(db):
return TagDefinition.objects.create( # pylint: disable=no-member
return TagDefinitionHistory.objects.create( # pylint: disable=no-member
name="tag definition party test",
id_parent_persistent=None,
type=TagDefinition.STRING,
Expand Down
73 changes: 49 additions & 24 deletions tests/entity/queue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import pytest

import tests.tag.common as ct
from tests.utils import assert_versioned
from vran.contribution.models_django import ContributionCandidate
from vran.entity.models_django import Entity
from vran.entity.queue import (
entity_display_txt_information_cache,
tag_def_db_to_dict,
update_display_txt_cache,
)
from vran.merge_request.models_django import TagMergeRequest
Expand Down Expand Up @@ -76,18 +78,20 @@ def test_without_display_txt_but_relevant_tag_instance(
)
assert result[0] == value_instance_tag_def_1
tag_def = result[1]
assert len(tag_def) == 8
assert "id" in tag_def
tag_def.pop("id")
assert tag_def == {
"id_persistent": ct.id_tag_def_persistent_test_user1,
"id_parent_persistent": None,
"name": ct.name_tag_def_test1,
"type": "STR",
"owner": {"username": "test-user1"},
"curated": False,
"hidden": False,
}
assert_versioned(
tag_def,
{
"id_persistent": ct.id_tag_def_persistent_test_user1,
"id_parent_persistent": None,
"name": ct.name_tag_def_test1,
"type": "STR",
"owner": {"username": "test-user1"},
"curated": False,
"hidden": False,
"disabled": False,
},
version_key="id",
)


def test_without_display_txt_and_no_relevant_tag_instance(
Expand Down Expand Up @@ -159,15 +163,36 @@ def test_contribution(contribution_instance_without_display_txt, display_txt_ord
)
assert result[0] == value_instance_tag_def_1
tag_def = result[1]
assert len(tag_def) == 8
assert "id" in tag_def
tag_def.pop("id")
assert tag_def == {
"id_persistent": ct.id_tag_def_persistent_test_user1,
"id_parent_persistent": None,
"name": ct.name_tag_def_test1,
"type": "STR",
"owner": {"username": "test-user1"},
"curated": False,
"hidden": False,
}
assert_versioned(
tag_def,
{
"id_persistent": ct.id_tag_def_persistent_test_user1,
"id_parent_persistent": None,
"name": ct.name_tag_def_test1,
"type": "STR",
"owner": {"username": "test-user1"},
"curated": False,
"hidden": False,
"disabled": False,
},
version_key="id",
)


def test_db_to_dict(tag_def):
tag_def.disabled = True
tag_def_dict = tag_def_db_to_dict(tag_def)
assert_versioned(
tag_def_dict,
{
"id_persistent": ct.id_tag_def_persistent_test,
"id_parent_persistent": None,
"name": ct.name_tag_def_test,
"type": "STR",
"owner": {"username": "test-user"},
"curated": False,
"hidden": False,
"disabled": True,
},
version_key="id",
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def test_append_to_existing(
)
assert rsp.status_code == 200
assert ConfigValue.get(DISPLAY_TXT_ORDER_CONFIG_KEY) == [
ct.id_tag_persistent_test,
ct.id_tag_def_persistent_test,
ct.id_tag_def_curated_test,
]
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ def test_three_element_order(auth_server_commissioner, display_txt_order_0_1_cur
{
"tag_definitions": [
{
"id_persistent": ct.id_tag_persistent_test,
"id_persistent": ct.id_tag_def_persistent_test,
"id_parent_persistent": None,
"name": ct.name_tag_def_test,
"name_path": [ct.name_tag_def_test],
"type": "STRING",
"curated": False,
"hidden": False,
"disabled": False,
"owner": "test-user",
},
{
Expand All @@ -61,6 +62,7 @@ def test_three_element_order(auth_server_commissioner, display_txt_order_0_1_cur
"type": "STRING",
"curated": False,
"hidden": False,
"disabled": False,
"owner": "test-user1",
},
{
Expand All @@ -71,6 +73,7 @@ def test_three_element_order(auth_server_commissioner, display_txt_order_0_1_cur
"type": "STRING",
"curated": True,
"hidden": False,
"disabled": False,
"owner": None,
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_unknown_tag_def(auth_server_commissioner):
def test_remove_only(auth_server_commissioner, display_txt_order_0):
server, cookies = auth_server_commissioner
rsp = req.delete_tag_definition(
server.url, ct.id_tag_persistent_test, cookies=cookies
server.url, ct.id_tag_def_persistent_test, cookies=cookies
)
assert rsp.status_code == 200
assert ConfigValue.get(DISPLAY_TXT_ORDER_CONFIG_KEY) == []
Expand All @@ -47,7 +47,7 @@ def test_remove_only(auth_server_commissioner, display_txt_order_0):
def test_remove_start(auth_server_commissioner, display_txt_order_0_1_curated):
server, cookies = auth_server_commissioner
rsp = req.delete_tag_definition(
server.url, ct.id_tag_persistent_test, cookies=cookies
server.url, ct.id_tag_def_persistent_test, cookies=cookies
)
assert rsp.status_code == 200
assert ConfigValue.get(DISPLAY_TXT_ORDER_CONFIG_KEY) == [
Expand All @@ -63,7 +63,7 @@ def test_remove_middle(auth_server_commissioner, display_txt_order_0_1_curated):
)
assert rsp.status_code == 200
assert ConfigValue.get(DISPLAY_TXT_ORDER_CONFIG_KEY) == [
ct.id_tag_persistent_test,
ct.id_tag_def_persistent_test,
ct.id_tag_def_curated_test,
]

Expand All @@ -75,6 +75,6 @@ def test_remove_end(auth_server_commissioner, display_txt_order_0_1_curated):
)
assert rsp.status_code == 200
assert ConfigValue.get(DISPLAY_TXT_ORDER_CONFIG_KEY) == [
ct.id_tag_persistent_test,
ct.id_tag_def_persistent_test,
ct.id_tag_def_persistent_test_user1,
]
Loading

0 comments on commit e88e805

Please sign in to comment.