[bug] Fix for data import (#13367)

* [bug] Fix for data import

Correctly skip plugin records (if requested) when importing data

* Fix for data export

* Updated CI workflow
This commit is contained in:
Oliver authored and GitHub committed 2026-11-25 20:31:33 +11:00
1 parent 65a8113baf
commit 5d24a3f327
5 files changed
+298 -14

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
"""Script to check the database state after an 'import-records --exclude-plugins' run.
This script is intended to be used as part of the CI workflow,
in conjunction with the "workflows/import_export.yaml" workflow
(see the 'exclude-plugins' job).
It checks that:
- Core data (e.g. Part records) was imported
- No plugin configuration was imported for the dummy plugin
Intended to be run from 'src/backend/InvenTree', e.g.:
cd src/backend/InvenTree && python ../../../.github/scripts/check_imported_data.py
"""
import os
import sys
sys.path.insert(0, os.getcwd())
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'InvenTree.settings')
import django
django.setup()
from part.models import Part
from plugin.models import PluginConfig, PluginSetting
PLUGIN_SLUG = 'dummy-app-plugin'
if __name__ == '__main__':
part_count = Part.objects.count()
if part_count == 0:
print('Error: Expected core Part data to be imported, but none was found')
sys.exit(1)
print(f'Confirmed {part_count} Part record(s) imported')
if PluginConfig.objects.filter(key=PLUGIN_SLUG).exists():
print(
f'Error: Plugin configuration for "{PLUGIN_SLUG}" was imported, but should have been excluded'
)
sys.exit(1)
if PluginSetting.objects.filter(plugin__key=PLUGIN_SLUG).exists():
print(
f'Error: Plugin settings for "{PLUGIN_SLUG}" were imported, but should have been excluded'
)
sys.exit(1)
print(f'Confirmed no plugin data was imported for "{PLUGIN_SLUG}"')
print('All checks passed successfully!')