Skip to content

Commit

Permalink
tests: re-use constant ELEMENT_DIFF_FIELD_NAME for import tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Mar 8, 2024
1 parent 2da0ca8 commit 079194e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion rdmo/management/tests/test_import_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from rdmo.conditions.models import Condition
from rdmo.core.imports import ELEMENT_DIFF_FIELD_NAME
from rdmo.management.imports import import_elements

from .helpers_import_elements import (
Expand Down Expand Up @@ -53,7 +54,7 @@ def test_update_conditions_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_legacy_conditions(db, settings):
Expand Down
3 changes: 2 additions & 1 deletion rdmo/management/tests/test_import_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from rdmo.core.imports import ELEMENT_DIFF_FIELD_NAME
from rdmo.domain.models import Attribute
from rdmo.management.imports import import_elements

Expand Down Expand Up @@ -53,7 +54,7 @@ def test_update_attributes_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_legacy_domain(db, settings):
Expand Down
4 changes: 2 additions & 2 deletions rdmo/management/tests/test_import_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_update_optionsets_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_update_optionsets_from_changed_xml(db, settings):
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_update_options_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]



Expand Down
11 changes: 6 additions & 5 deletions rdmo/management/tests/test_import_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from rdmo.core.imports import ELEMENT_DIFF_FIELD_NAME
from rdmo.management.imports import import_elements
from rdmo.questions.models import Catalog, Page, Question, QuestionSet, Section

Expand Down Expand Up @@ -64,7 +65,7 @@ def test_update_catalogs_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_sections(db, settings):
Expand Down Expand Up @@ -114,7 +115,7 @@ def test_update_sections_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_pages(db, settings):
Expand Down Expand Up @@ -163,7 +164,7 @@ def test_update_pages_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_questionsets(db, settings):
Expand Down Expand Up @@ -214,7 +215,7 @@ def test_update_questionsets_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_questions(db, settings):
Expand Down Expand Up @@ -261,7 +262,7 @@ def test_update_questions_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_legacy_questions(db, settings):
Expand Down
3 changes: 2 additions & 1 deletion rdmo/management/tests/test_import_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from rdmo.core.imports import ELEMENT_DIFF_FIELD_NAME
from rdmo.management.imports import import_elements
from rdmo.tasks.models import Task

Expand Down Expand Up @@ -53,7 +54,7 @@ def test_update_tasks_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_legacy_tasks(db, settings):
Expand Down
3 changes: 2 additions & 1 deletion rdmo/management/tests/test_import_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from rdmo.core.imports import ELEMENT_DIFF_FIELD_NAME
from rdmo.management.imports import import_elements
from rdmo.views.models import View

Expand Down Expand Up @@ -53,7 +54,7 @@ def test_update_views_with_changed_fields(db, settings, updated_fields):
assert len(imported_and_changed) == len(changed_elements)
# compare two ordered lists with "updated_and_changed" dicts
for test, imported in zip(changed_elements, imported_and_changed):
assert test['updated_and_changed'] == imported['updated_and_changed']
assert test[ELEMENT_DIFF_FIELD_NAME] == imported[ELEMENT_DIFF_FIELD_NAME]


def test_create_legacy_tasks(db, settings):
Expand Down

0 comments on commit 079194e

Please sign in to comment.