def netbox(db, management_profile): box = Netbox(ip='10.254.254.254', sysname='example-sw.example.org', organization_id='myorg', room_id='myroom', category_id='SW') box.save() NetboxProfile(netbox=box, profile=management_profile).save() device = Device(serial="1234test") device.save() module = Module(device=device, netbox=box, name='Module 1', model='') module.save() interface = Interface(netbox=box, module=module, ifname='1', ifdescr='Port 1') interface.save() return box
def netbox(db): box = Netbox(ip='10.254.254.254', sysname='example-sw.example.org', organization_id='myorg', room_id='myroom', category_id='SW', snmp_version=2, read_only='public') box.save() device = Device(serial="1234test") device.save() module = Module(device=device, netbox=box, name='Module 1', model='') module.save() interface = Interface(netbox=box, module=module, ifname='1', ifdescr='Port 1') interface.save() return box
def test_netbox_should_be_annotated_with_chassis_serial(db, localhost): """Mainly, this verifies that regressions haven't rendered the raw SQL used to annotate netboxes with serial numbers incompatible with the current schema. """ for index, serial in enumerate(["first", "second"]): device = Device(serial=serial) device.save() chassis = NetboxEntity( netbox=localhost, device=device, index=index, physical_class=NetboxEntity.CLASS_CHASSIS, ) chassis.save() netbox = Netbox.objects.with_chassis_serials().filter(id=localhost.id)[0] assert netbox.chassis_serial == "first"