mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-23 13:52:17 -06:00
Split out NetBoxTable from BaseTable
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
from django.template import Context, Template
|
||||
from django.test import TestCase
|
||||
|
||||
from dcim.models import Site
|
||||
from netbox.tables import BaseTable, columns
|
||||
from utilities.testing import create_tags
|
||||
|
||||
|
||||
class TagColumnTable(BaseTable):
|
||||
tags = columns.TagColumn(url_name='dcim:site_list')
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = Site
|
||||
fields = ('pk', 'name', 'tags',)
|
||||
default_columns = fields
|
||||
|
||||
|
||||
class TagColumnTest(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
||||
|
||||
sites = [
|
||||
Site(name=f'Site {i}', slug=f'site-{i}') for i in range(1, 6)
|
||||
]
|
||||
Site.objects.bulk_create(sites)
|
||||
for site in sites:
|
||||
site.tags.add(*tags)
|
||||
|
||||
def test_tagcolumn(self):
|
||||
template = Template('{% load render_table from django_tables2 %}{% render_table table %}')
|
||||
table = TagColumnTable(Site.objects.all(), orderable=False)
|
||||
context = Context({
|
||||
'table': table
|
||||
})
|
||||
template.render(context)
|
||||
Reference in New Issue
Block a user