mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 09:53:34 -06:00
Suppress print() output from migrations during testing
This commit is contained in:
parent
7ffb5f16dd
commit
62da0778ee
@ -1,3 +1,5 @@
|
||||
import sys
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
@ -18,7 +20,8 @@ def circuit_terminations_to_cables(apps, schema_editor):
|
||||
interface_type = ContentType.objects.get_for_model(Interface)
|
||||
|
||||
# Create a new Cable instance from each console connection
|
||||
print("\n Adding circuit terminations... ", end='', flush=True)
|
||||
if 'test' not in sys.argv:
|
||||
print("\n Adding circuit terminations... ", end='', flush=True)
|
||||
for circuittermination in CircuitTermination.objects.filter(interface__isnull=False):
|
||||
|
||||
# Create the new Cable
|
||||
@ -44,7 +47,8 @@ def circuit_terminations_to_cables(apps, schema_editor):
|
||||
)
|
||||
|
||||
cable_count = Cable.objects.filter(termination_a_type=circuittermination_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
if 'test' not in sys.argv:
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -71,7 +75,7 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='circuittermination',
|
||||
name='cable',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='dcim.Cable'),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='dcim.Cable'),
|
||||
),
|
||||
|
||||
# Copy CircuitTermination connections to Interfaces as Cables
|
||||
|
@ -1,5 +1,8 @@
|
||||
import sys
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
import utilities.fields
|
||||
|
||||
|
||||
@ -17,7 +20,8 @@ def console_connections_to_cables(apps, schema_editor):
|
||||
consoleserverport_type = ContentType.objects.get_for_model(ConsoleServerPort)
|
||||
|
||||
# Create a new Cable instance from each console connection
|
||||
print("\n Adding console connections... ", end='', flush=True)
|
||||
if 'test' not in sys.argv:
|
||||
print("\n Adding console connections... ", end='', flush=True)
|
||||
for consoleport in ConsolePort.objects.filter(connected_endpoint__isnull=False):
|
||||
|
||||
# Create the new Cable
|
||||
@ -34,7 +38,8 @@ def console_connections_to_cables(apps, schema_editor):
|
||||
ConsoleServerPort.objects.filter(pk=consoleport.connected_endpoint_id).update(cable=cable)
|
||||
|
||||
cable_count = Cable.objects.filter(termination_a_type=consoleport_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
if 'test' not in sys.argv:
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
def power_connections_to_cables(apps, schema_editor):
|
||||
@ -51,7 +56,8 @@ def power_connections_to_cables(apps, schema_editor):
|
||||
poweroutlet_type = ContentType.objects.get_for_model(PowerOutlet)
|
||||
|
||||
# Create a new Cable instance from each power connection
|
||||
print(" Adding power connections... ", end='', flush=True)
|
||||
if 'test' not in sys.argv:
|
||||
print(" Adding power connections... ", end='', flush=True)
|
||||
for powerport in PowerPort.objects.filter(connected_endpoint__isnull=False):
|
||||
|
||||
# Create the new Cable
|
||||
@ -68,7 +74,8 @@ def power_connections_to_cables(apps, schema_editor):
|
||||
PowerOutlet.objects.filter(pk=powerport.connected_endpoint_id).update(cable=cable)
|
||||
|
||||
cable_count = Cable.objects.filter(termination_a_type=powerport_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
if 'test' not in sys.argv:
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
def interface_connections_to_cables(apps, schema_editor):
|
||||
@ -84,7 +91,8 @@ def interface_connections_to_cables(apps, schema_editor):
|
||||
interface_type = ContentType.objects.get_for_model(Interface)
|
||||
|
||||
# Create a new Cable instance from each InterfaceConnection
|
||||
print(" Adding interface connections... ", end='', flush=True)
|
||||
if 'test' not in sys.argv:
|
||||
print(" Adding interface connections... ", end='', flush=True)
|
||||
for conn in InterfaceConnection.objects.all():
|
||||
|
||||
# Create the new Cable
|
||||
@ -109,7 +117,8 @@ def interface_connections_to_cables(apps, schema_editor):
|
||||
)
|
||||
|
||||
cable_count = Cable.objects.filter(termination_a_type=interface_type).count()
|
||||
print("{} cables created".format(cable_count))
|
||||
if 'test' not in sys.argv:
|
||||
print("{} cables created".format(cable_count))
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
Loading…
Reference in New Issue
Block a user