Tests actually work again

This commit is contained in:
2021-02-08 15:17:09 +00:00
parent ef1d9868da
commit e48e016cb9
6 changed files with 109 additions and 124 deletions

View File

@@ -7,6 +7,7 @@ from reversion import revisions as reversion
from RIGS import models as rigsmodels
from assets import models
from assets.models import get_available_asset_id
class Command(BaseCommand):
@@ -34,6 +35,11 @@ class Command(BaseCommand):
self.create_connectors()
self.create_cables()
def create_categories(self):
choices = ['Case', 'Video', 'General', 'Sound', 'Lighting', 'Rigging']
for cat in choices:
self.categories.append(models.AssetCategory.objects.create(name=cat))
def create_statuses(self):
choices = [('In Service', True, 'success'), ('Lost', False, 'warning'), ('Binned', False, 'danger'), ('Sold', False, 'danger'), ('Broken', False, 'warning')]
for stat in choices:
@@ -42,24 +48,18 @@ class Command(BaseCommand):
def create_suppliers(self):
choices = ["Acme, inc.", "Widget Corp", "123 Warehousing", "Demo Company", "Smith and Co.", "Foo Bars", "ABC Telecom", "Fake Brothers", "QWERTY Logistics", "Demo, inc.", "Sample Company", "Sample, inc", "Acme Corp", "Allied Biscuit", "Ankh-Sto Associates", "Extensive Enterprise", "Galaxy Corp", "Globo-Chem", "Mr. Sparkle", "Globex Corporation", "LexCorp", "LuthorCorp", "North Central Positronics", "Omni Consimer Products", "Praxis Corporation", "Sombra Corporation", "Sto Plains Holdings", "Tessier-Ashpool", "Wayne Enterprises", "Wentworth Industries", "ZiffCorp", "Bluth Company", "Strickland Propane", "Thatherton Fuels", "Three Waters", "Water and Power", "Western Gas & Electric", "Mammoth Pictures", "Mooby Corp", "Gringotts", "Thrift Bank", "Flowers By Irene", "The Legitimate Businessmens Club", "Osato Chemicals", "Transworld Consortium", "Universal Export", "United Fried Chicken", "Virtucon", "Kumatsu Motors", "Keedsler Motors", "Powell Motors", "Industrial Automation", "Sirius Cybernetics Corporation", "U.S. Robotics and Mechanical Men", "Colonial Movers", "Corellian Engineering Corporation", "Incom Corporation", "General Products", "Leeding Engines Ltd.", "Blammo", # noqa
"Input, Inc.", "Mainway Toys", "Videlectrix", "Zevo Toys", "Ajax", "Axis Chemical Co.", "Barrytron", "Carrys Candles", "Cogswell Cogs", "Spacely Sprockets", "General Forge and Foundry", "Duff Brewing Company", "Dunder Mifflin", "General Services Corporation", "Monarch Playing Card Co.", "Krustyco", "Initech", "Roboto Industries", "Primatech", "Sonky Rubber Goods", "St. Anky Beer", "Stay Puft Corporation", "Vandelay Industries", "Wernham Hogg", "Gadgetron", "Burleigh and Stronginthearm", "BLAND Corporation", "Nordyne Defense Dynamics", "Petrox Oil Company", "Roxxon", "McMahon and Tate", "Sixty Second Avenue", "Charles Townsend Agency", "Spade and Archer", "Megadodo Publications", "Rouster and Sideways", "C.H. Lavatory and Sons", "Globo Gym American Corp", "The New Firm", "SpringShield", "Compuglobalhypermeganet", "Data Systems", "Gizmonic Institute", "Initrode", "Taggart Transcontinental", "Atlantic Northern", "Niagular", "Plow King", "Big Kahuna Burger", "Big T Burgers and Fries", "Chez Quis", "Chotchkies", "The Frying Dutchman", "Klimpys", "The Krusty Krab", "Monks Diner", "Milliways", "Minuteman Cafe", "Taco Grande", "Tip Top Cafe", "Moes Tavern", "Central Perk", "Chasers"] # noqa
pk = 1
for supplier in choices:
self.suppliers.append(models.Supplier.objects.create(name=supplier))
pk += 1
def create_categories(self):
choices = ['Case', 'Video', 'General', 'Sound', 'Lighting', 'Rigging']
for cat in choices:
self.categories.append(models.AssetCategory.objects.create(name=cat))
def create_assets(self):
asset_description = ['Large cable', 'Shiny thing', 'New lights', 'Really expensive microphone', 'Box of fuse flaps', 'Expensive tool we didn\'t agree to buy', 'Cable drums', 'Boring amount of tape', 'Video stuff no one knows how to use', 'More amplifiers', 'Heatshrink']
with reversion.create_revision():
for i in range(100):
for i in range(100):
with reversion.create_revision():
reversion.set_user(random.choice(rigsmodels.Profile.objects.all()))
asset_id = str(get_available_asset_id())
asset = models.Asset(
asset_id='{}'.format(get_available_asset_id()),
asset_id=asset_id,
description=random.choice(asset_description),
category=random.choice(self.categories),
status=random.choice(self.statuses),
@@ -70,7 +70,8 @@ class Command(BaseCommand):
asset.parent = models.Asset.objects.order_by('?').first()
if i % 3 == 0:
asset.purchased_from = random.choice(suppliers)
asset.purchased_from = random.choice(self.suppliers)
asset.clean()
asset.save()
@@ -96,12 +97,15 @@ class Command(BaseCommand):
circuits = [1, 2, 3, 6]
types = []
for i in range(len(connectors)):
for i in range(len(self.connectors)):
types.append(models.CableType.objects.create(plug=random.choice(self.connectors), socket=random.choice(self.connectors), circuits=random.choice(circuits), cores=random.choice(cores)))
for i in range(100):
prefix = random.choice(asset_prefixes)
asset_id = str(get_available_asset_id(wanted_prefix=prefix))
asset_id = prefix + asset_id
asset = models.Asset(
asset_id='{}'.format(get_available_asset_id()),
asset_id=asset_id,
description=random.choice(asset_description),
category=random.choice(self.categories),
status=random.choice(self.statuses),
@@ -113,15 +117,11 @@ class Command(BaseCommand):
length=random.choice(lengths),
)
if i % 5 == 0:
prefix = random.choice(asset_prefixes)
asset.asset_id = prefix + str(get_available_asset_id(wanted_prefix=prefix))
if i % 4 == 0:
asset.parent = models.Asset.objects.order_by('?').first()
if i % 3 == 0:
asset.purchased_from = random.choice(suppliers)
asset.purchased_from = random.choice(self.suppliers)
asset.clean()
asset.save()