Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions openedx_tagging/core/tagging/import_export/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def import_tags(
in the file (regardless of action), then `tag_2` and `tag_3` will be deleted
if `replace=True`
"""
_import_export_validations(taxonomy)
_import_validations(taxonomy)

# Checks that exists only one task import in progress at a time per taxonomy
if not _check_unique_import_task(taxonomy):
Expand Down Expand Up @@ -146,7 +146,6 @@ def export_tags(taxonomy: Taxonomy, output_format: ParserFormat) -> str:
"""
Returns a string with all tag data of the given taxonomy
"""
_import_export_validations(taxonomy)
parser = get_parser(output_format)
return parser.export(taxonomy)

Expand Down Expand Up @@ -178,20 +177,20 @@ def _get_last_import_task(taxonomy: Taxonomy) -> TagImportTask | None:
)


def _import_export_validations(taxonomy: Taxonomy):
def _import_validations(taxonomy: Taxonomy):
"""
Validates if the taxonomy is allowed to import or export tags
"""
taxonomy = taxonomy.cast()
if taxonomy.allow_free_text:
raise NotImplementedError(
_(
"Import/export for free-form taxonomies will be implemented in the future."
"Import for free-form taxonomies will be implemented in the future."
Comment thread
bradenmacdonald marked this conversation as resolved.
Outdated
)
)
if taxonomy.system_defined:
raise ValueError(
_(
"Invalid taxonomy ({id}): You cannot import/export a system-defined taxonomy."
"Invalid taxonomy ({id}): You cannot import a system-defined taxonomy."
).format(id=taxonomy.id)
)
15 changes: 0 additions & 15 deletions tests/openedx_tagging/core/tagging/import_export/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,6 @@ def test_start_task_after_success(self) -> None:
self.parser_format,
)

def test_export_validations(self) -> None:
# Check that import is invalid with open taxonomy
with self.assertRaises(NotImplementedError):
import_export_api.export_tags(
self.open_taxonomy,
self.parser_format,
)

# Check that import is invalid with system taxonomy
with self.assertRaises(ValueError):
import_export_api.export_tags(
self.system_taxonomy,
self.parser_format,
)

def test_import_with_export_output(self) -> None:
for parser_format in ParserFormat:
output = import_export_api.export_tags(
Expand Down