Beispiel #1
0
    def test_maintenance_mode(self):
        foo = DeviceType(name='foo')
        device = Device(device_type=foo, hostname='foo01', status=Device.IDLE)
        device.save()

        device.put_into_maintenance_mode(None, None)

        self.assertEqual(device.status, Device.OFFLINE, "should be offline")

        device.status = Device.RUNNING
        device.put_into_maintenance_mode(None, None)

        self.assertEqual(device.status, Device.OFFLINING, "should be offlining")
Beispiel #2
0
    def test_maintenance_mode(self):
        foo = DeviceType(name='foo')
        device = Device(device_type=foo, hostname='foo01', status=Device.IDLE)
        device.save()

        device.put_into_maintenance_mode(None, None)

        self.assertEqual(device.status, Device.OFFLINE, "should be offline")

        device.status = Device.RUNNING
        device.put_into_maintenance_mode(None, None)

        self.assertEqual(device.status, Device.OFFLINING,
                         "should be offlining")
Beispiel #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')))
Beispiel #4
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')))