mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
More migration to fixtures
This commit is contained in:
@@ -4,17 +4,23 @@ import datetime
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_cable(db):
|
||||
category = models.AssetCategory.objects.create(name="Sound")
|
||||
status = models.AssetStatus.objects.create(name="Broken", should_show=True)
|
||||
def category(db):
|
||||
return models.AssetCategory.objects.create(name="Sound")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def status(db):
|
||||
return models.AssetStatus.objects.create(name="Broken", should_show=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_cable(db, category, status):
|
||||
connector = models.Connector.objects.create(description="16A IEC", current_rating=16, voltage_rating=240, num_pins=3)
|
||||
cable_type = models.CableType.objects.create(circuits=11, cores=3, plug=connector, socket=connector)
|
||||
return models.Asset.objects.create(asset_id="666", description="125A -> Jack", comments="The cable from Hell...", status=status, category=category, date_acquired=datetime.date(2006, 6, 6), is_cable=True, cable_type=cable_type, length=10, csa="1.5")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_asset(db):
|
||||
working = models.AssetStatus.objects.create(name="Working", should_show=True)
|
||||
lighting = models.AssetCategory.objects.create(name="Lighting")
|
||||
def test_asset(db, category, status):
|
||||
asset = models.Asset.objects.create(asset_id="1991", description="Spaceflower", status=working, category=lighting, date_acquired=datetime.date(1991, 12, 26))
|
||||
return asset
|
||||
|
||||
@@ -16,7 +16,8 @@ from django.utils import timezone
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
@pytest.fixture(scope='module')
|
||||
@pytest.mark.db(transaction=True)
|
||||
def django_db_setup(django_db_setup, django_db_blocker): # We need stuff setup so we don't get 404 errors everywhere
|
||||
with django_db_blocker.unblock():
|
||||
from django.conf import settings
|
||||
|
||||
@@ -2,8 +2,6 @@ import datetime
|
||||
|
||||
import pytest
|
||||
from django.core.management import call_command
|
||||
from django.test import override_settings
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from pytest_django.asserts import assertFormError, assertRedirects, assertContains, assertNotContains
|
||||
|
||||
@@ -89,6 +87,7 @@ def test_oembed(client, test_asset):
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_generate_sample_data(settings):
|
||||
settings.DEBUG = True
|
||||
call_command('deleteSampleData') # TODO
|
||||
# Run the management command and check there are no exceptions
|
||||
call_command('generateSampleAssetsData')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user