mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-19 01:58:43 -06:00
Initial work on contacts
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from tenancy.models import Tenant, TenantGroup
|
||||
from tenancy.models import *
|
||||
from utilities.testing import ViewTestCases, create_tags
|
||||
|
||||
|
||||
@@ -74,3 +74,105 @@ class TenantTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
cls.bulk_edit_data = {
|
||||
'group': tenant_groups[1].pk,
|
||||
}
|
||||
|
||||
|
||||
class ContactGroupTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
model = ContactGroup
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
||||
contact_groups = (
|
||||
ContactGroup(name='Contact Group 1', slug='contact-group-1'),
|
||||
ContactGroup(name='Contact Group 2', slug='contact-group-2'),
|
||||
ContactGroup(name='Contact Group 3', slug='contact-group-3'),
|
||||
)
|
||||
for tenanantgroup in contact_groups:
|
||||
tenanantgroup.save()
|
||||
|
||||
cls.form_data = {
|
||||
'name': 'Contact Group X',
|
||||
'slug': 'contact-group-x',
|
||||
'description': 'A new contact group',
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,slug,description",
|
||||
"Contact Group 4,contact-group-4,Fourth contact group",
|
||||
"Contact Group 5,contact-group-5,Fifth contact group",
|
||||
"Contact Group 6,contact-group-6,Sixth contact group",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class ContactRoleTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
model = ContactRole
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
||||
ContactRole.objects.bulk_create([
|
||||
ContactRole(name='Contact Role 1', slug='contact-role-1'),
|
||||
ContactRole(name='Contact Role 2', slug='contact-role-2'),
|
||||
ContactRole(name='Contact Role 3', slug='contact-role-3'),
|
||||
])
|
||||
|
||||
cls.form_data = {
|
||||
'name': 'Devie Role X',
|
||||
'slug': 'contact-role-x',
|
||||
'description': 'New contact role',
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,slug",
|
||||
"Contact Role 4,contact-role-4",
|
||||
"Contact Role 5,contact-role-5",
|
||||
"Contact Role 6,contact-role-6",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
class ContactTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
||||
model = Contact
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
||||
contact_groups = (
|
||||
ContactGroup(name='Contact Group 1', slug='contact-group-1'),
|
||||
ContactGroup(name='Contact Group 2', slug='contact-group-2'),
|
||||
)
|
||||
for contactgroup in contact_groups:
|
||||
contactgroup.save()
|
||||
|
||||
Contact.objects.bulk_create([
|
||||
Contact(name='Contact 1', group=contact_groups[0]),
|
||||
Contact(name='Contact 2', group=contact_groups[0]),
|
||||
Contact(name='Contact 3', group=contact_groups[0]),
|
||||
])
|
||||
|
||||
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
||||
|
||||
cls.form_data = {
|
||||
'name': 'Contact X',
|
||||
'group': contact_groups[1].pk,
|
||||
'comments': 'Some comments',
|
||||
'tags': [t.pk for t in tags],
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,slug",
|
||||
"Contact 4,contact-4",
|
||||
"Contact 5,contact-5",
|
||||
"Contact 6,contact-6",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'group': contact_groups[1].pk,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user