mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Reorganize base TestCase classes
This commit is contained in:
@ -3,8 +3,10 @@ import re
|
||||
from contextlib import contextmanager
|
||||
|
||||
from django.contrib.auth.models import Permission, User
|
||||
from django.utils.text import slugify
|
||||
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site
|
||||
from extras.models import Tag
|
||||
|
||||
|
||||
def post_data(data):
|
||||
@ -59,6 +61,15 @@ def create_test_user(username='testuser', permissions=None):
|
||||
return user
|
||||
|
||||
|
||||
def create_tags(*names):
|
||||
"""
|
||||
Create and return a Tag instance for each name given.
|
||||
"""
|
||||
tags = [Tag(name=name, slug=slugify(name)) for name in names]
|
||||
Tag.objects.bulk_create(tags)
|
||||
return tags
|
||||
|
||||
|
||||
def extract_form_failures(content):
|
||||
"""
|
||||
Given raw HTML content from an HTTP response, return a list of form errors.
|
||||
|
Reference in New Issue
Block a user