mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 03:16:25 -06:00
Clean up bulk import & extend tests
This commit is contained in:
parent
750e325a36
commit
1d533c4e4a
@ -179,6 +179,15 @@ class CircuitGroupImportForm(NetBoxModelImportForm):
|
||||
|
||||
|
||||
class CircuitGroupAssignmentImportForm(NetBoxModelImportForm):
|
||||
member_type = CSVContentTypeField(
|
||||
queryset=ContentType.objects.filter(CIRCUIT_GROUP_ASSIGNMENT_MEMBER_MODELS),
|
||||
label=_('Circuit type (app & model)')
|
||||
)
|
||||
priority = CSVChoiceField(
|
||||
label=_('Priority'),
|
||||
choices=CircuitPriorityChoices,
|
||||
required=False
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = CircuitGroupAssignment
|
||||
|
@ -191,7 +191,9 @@ class CircuitGroupAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin,
|
||||
on_delete=models.PROTECT,
|
||||
related_name='+'
|
||||
)
|
||||
member_id = models.PositiveBigIntegerField()
|
||||
member_id = models.PositiveBigIntegerField(
|
||||
verbose_name=_('member ID')
|
||||
)
|
||||
member = GenericForeignKey(
|
||||
ct_field='member_type',
|
||||
fk_field='member_id'
|
||||
|
@ -468,6 +468,7 @@ class CircuitGroupAssignmentTestCase(
|
||||
ViewTestCases.DeleteObjectViewTestCase,
|
||||
ViewTestCases.ListObjectsViewTestCase,
|
||||
ViewTestCases.BulkEditObjectsViewTestCase,
|
||||
ViewTestCases.BulkImportObjectsViewTestCase,
|
||||
ViewTestCases.BulkDeleteObjectsViewTestCase
|
||||
):
|
||||
model = CircuitGroupAssignment
|
||||
@ -523,6 +524,20 @@ class CircuitGroupAssignmentTestCase(
|
||||
'tags': [t.pk for t in tags],
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"member_type,member_id,group,priority",
|
||||
f"circuits.circuit,{circuits[0].pk},{circuit_groups[3].pk},primary",
|
||||
f"circuits.circuit,{circuits[1].pk},{circuit_groups[3].pk},secondary",
|
||||
f"circuits.circuit,{circuits[2].pk},{circuit_groups[3].pk},tertiary",
|
||||
)
|
||||
|
||||
cls.csv_update_data = (
|
||||
"id,priority",
|
||||
f"{assignments[0].pk},inactive",
|
||||
f"{assignments[1].pk},inactive",
|
||||
f"{assignments[2].pk},inactive",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'priority': CircuitPriorityChoices.PRIORITY_INACTIVE,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user