mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 00:36:11 -06:00
7961 update tests
This commit is contained in:
parent
3c32968b5f
commit
a9ce58538d
@ -50,6 +50,13 @@ class ProviderTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
"Provider 6,provider-6",
|
"Provider 6,provider-6",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.csv_update_data = (
|
||||||
|
"name,comments",
|
||||||
|
"Provider 7,New comment7",
|
||||||
|
"Provider 8,New comment8",
|
||||||
|
"Provider 9,New comment9",
|
||||||
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'account': '5678',
|
'account': '5678',
|
||||||
'comments': 'New comments',
|
'comments': 'New comments',
|
||||||
@ -84,6 +91,13 @@ class CircuitTypeTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
|||||||
"Circuit Type 6,circuit-type-6",
|
"Circuit Type 6,circuit-type-6",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.csv_update_data = (
|
||||||
|
"name,description",
|
||||||
|
"Circuit Type 7,New description7",
|
||||||
|
"Circuit Type 8,New description8",
|
||||||
|
"Circuit Type 9,New description9",
|
||||||
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'description': 'Foo',
|
'description': 'Foo',
|
||||||
}
|
}
|
||||||
@ -136,6 +150,13 @@ class CircuitTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
"Circuit 6,Provider 1,Circuit Type 1,active",
|
"Circuit 6,Provider 1,Circuit Type 1,active",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.csv_update_data = (
|
||||||
|
f"cid,description,status",
|
||||||
|
f"Circuit 7,New description7,{CircuitStatusChoices.STATUS_DECOMMISSIONED}",
|
||||||
|
f"Circuit 8,New description8,{CircuitStatusChoices.STATUS_DECOMMISSIONED}",
|
||||||
|
f"Circuit 9,New description9,{CircuitStatusChoices.STATUS_DECOMMISSIONED}",
|
||||||
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'provider': providers[1].pk,
|
'provider': providers[1].pk,
|
||||||
'type': circuittypes[1].pk,
|
'type': circuittypes[1].pk,
|
||||||
@ -182,6 +203,13 @@ class ProviderNetworkTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
"Provider Network 6,Provider 1,Baz",
|
"Provider Network 6,Provider 1,Baz",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.csv_update_data = (
|
||||||
|
"name,description",
|
||||||
|
"Provider Network 7,New description7",
|
||||||
|
"Provider Network 8,New description8",
|
||||||
|
"Provider Network 9,New description9",
|
||||||
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
'provider': providers[1].pk,
|
'provider': providers[1].pk,
|
||||||
'description': 'New description',
|
'description': 'New description',
|
||||||
|
@ -549,17 +549,13 @@ class ViewTestCases:
|
|||||||
return '\n'.join(self.csv_data)
|
return '\n'.join(self.csv_data)
|
||||||
|
|
||||||
def _get_update_csv_data(self, start):
|
def _get_update_csv_data(self, start):
|
||||||
# bulk_edit_data is dict, convert to comma-separated string
|
|
||||||
header = ",".join(self.bulk_edit_data.keys())
|
|
||||||
update_line = ",".join(self.bulk_edit_data.values())
|
|
||||||
|
|
||||||
# pre-pend id into data
|
# pre-pend id into data
|
||||||
csv_data = []
|
csv_data = []
|
||||||
for idx, line in enumerate(self.csv_data, start=start):
|
for idx, line in enumerate(self.csv_update_data, start=start):
|
||||||
if idx == start:
|
if idx == start:
|
||||||
csv_data.append("id," + header)
|
csv_data.append("id," + line)
|
||||||
else:
|
else:
|
||||||
csv_data.append(f"{idx-1}," + update_line)
|
csv_data.append(f"{idx-1}," + line)
|
||||||
|
|
||||||
return csv_data, '\n'.join(csv_data)
|
return csv_data, '\n'.join(csv_data)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user