def test_put_into_looping_mode(self):
        foo = DeviceType(name='foo')
        device = Device(device_type=foo, hostname='foo01', status=Device.OFFLINE)
        device.save()

        device.put_into_looping_mode(None, None)

        self.assertEqual(device.status, Device.IDLE, "should be IDLE")
        self.assertEqual(device.health_status, Device.HEALTH_LOOPING, "should be LOOPING")
示例#2
0
    def test_create_logentry(self):
        foo = DeviceType(name='foo')
        device = Device(device_type=foo, hostname='foo01', status=Device.OFFLINE)
        device.save()

        # only unit tests should call these functions with None, None
        # if that is made a requirement of the device status functions, fix this test.
        device.put_into_looping_mode(None, None)
        self.assertEqual(device.status, Device.IDLE, "should be IDLE")
        self.assertEqual(device.health_status, Device.HEALTH_LOOPING, "should be LOOPING")
        device_ct = ContentType.objects.get_for_model(Device)
        self.assertEqual(0, len(LogEntry.objects.filter(content_type=device_ct, action_flag=2).order_by('-action_time')))

        user = self.factory.make_user()
        device.put_into_maintenance_mode(user, 'test_create_logentry')
        self.assertEqual(device.status, Device.OFFLINE, "should be OFFLINE")
        self.assertEqual(device.health_status, Device.HEALTH_UNKNOWN, "should be UNKNOWN")
        # the device state transition also creates a log entry
        self.assertEqual(2, len(LogEntry.objects.filter(content_type=device_ct, action_flag=2).order_by('-action_time')))
示例#3
0
    def test_create_logentry(self):
        foo = DeviceType(name='foo')
        device = Device(device_type=foo, hostname='foo01', status=Device.OFFLINE)
        device.save()

        # only unit tests should call these functions with None, None
        # if that is made a requirement of the device status functions, fix this test.
        device.put_into_looping_mode(None, None)
        self.assertEqual(device.status, Device.IDLE, "should be IDLE")
        self.assertEqual(device.health_status, Device.HEALTH_LOOPING, "should be LOOPING")
        device_ct = ContentType.objects.get_for_model(Device)
        self.assertEqual(0, len(LogEntry.objects.filter(content_type=device_ct, action_flag=2).order_by('-action_time')))

        user = self.factory.make_user()
        device.put_into_maintenance_mode(user, 'test_create_logentry')
        self.assertEqual(device.status, Device.OFFLINE, "should be OFFLINE")
        self.assertEqual(device.health_status, Device.HEALTH_UNKNOWN, "should be UNKNOWN")
        # the device state transition also creates a log entry
        self.assertEqual(2, len(LogEntry.objects.filter(content_type=device_ct, action_flag=2).order_by('-action_time')))