mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Adds csv dialect detection to bulk import view (#13563)
* adds csv dialect detection to bulk import view #13239 * adds sane delimiters for dialect detection #13239 * adds csv delimiter tests #13239 * adds csv delimiter on the form * pass delimiter to clean_csv method #13239 * fix tests for csv import #13239 * fix tests for csv import #13239 * fix tests for csv import #13239 * fix tests for csv import #13239 * Improve auto-detection of import data format * Misc cleanup * Include tab as a supported delimiting character for auto-detection * Move delimiting chars to a separate constant for easy reference --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
committed by
GitHub
parent
39cb9c32d6
commit
b7cfb2f7d9
@@ -12,6 +12,7 @@ from dcim.models import Manufacturer, Rack, Site
|
||||
from extras.choices import *
|
||||
from extras.models import CustomField, CustomFieldChoiceSet
|
||||
from ipam.models import VLAN
|
||||
from utilities.choices import CSVDelimiterChoices, ImportFormatChoices
|
||||
from utilities.testing import APITestCase, TestCase
|
||||
from virtualization.models import VirtualMachine
|
||||
|
||||
@@ -1176,7 +1177,11 @@ class CustomFieldImportTest(TestCase):
|
||||
)
|
||||
csv_data = '\n'.join(','.join(row) for row in data)
|
||||
|
||||
response = self.client.post(reverse('dcim:site_import'), {'data': csv_data, 'format': 'csv'})
|
||||
response = self.client.post(reverse('dcim:site_import'), {
|
||||
'data': csv_data,
|
||||
'format': ImportFormatChoices.CSV,
|
||||
'csv_delimiter': CSVDelimiterChoices.AUTO,
|
||||
})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(Site.objects.count(), 3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user