def _prepare_data_for_device_tests(self): self.sample_device = Device.create( sn='sn_123456789_1', model_name='sampleDevice', model_type=DeviceType.unknown, ) self.other_sample_device = Device.create( sn='sn_123456789_2', model_name='otherSampleDevice', model_type=DeviceType.unknown, ) created = datetime.datetime.now() - datetime.timedelta(days=31) change = CIChange( type=CI_CHANGE_TYPES.DEVICE, content_type=ContentType.objects.get_for_model( self.sample_device, ), object_id=self.sample_device.id, created=created, priority=CI_CHANGE_PRIORITY_TYPES.ERROR, ) change.save() self.cichange_device_id = change.id change = CIChange( type=CI_CHANGE_TYPES.DEVICE, content_type=ContentType.objects.get_for_model( self.other_sample_device, ), object_id=self.other_sample_device.id, created=created + datetime.timedelta(days=2), priority=CI_CHANGE_PRIORITY_TYPES.ERROR, ) change.save() self.not_touched_cichange_device_id = change.id
def _prepare_data_for_zabbix_tests(self): zabbix_change_1 = CIChangeZabbixTrigger( trigger_id=123, host='example.com', host_id=123, status=1, priority=1, description='...', lastchange='...', comments='...', ) zabbix_change_1.save() self.zabbix_change_1_id = zabbix_change_1.id change = CIChange( type=CI_CHANGE_TYPES.ZABBIX_TRIGGER, content_type=ContentType.objects.get_for_model(zabbix_change_1), object_id=self.zabbix_change_1_id, created=datetime.datetime.now() - datetime.timedelta(days=31), priority=CI_CHANGE_PRIORITY_TYPES.ERROR, ) change.save() self.cichange_zabbix_id = change.id zabbix_change_2 = CIChangeZabbixTrigger( trigger_id=321, host='host.com', host_id=321, status=1, priority=1, description='...', lastchange='...', comments='...', ) zabbix_change_2.save() self.zabbix_change_2_id = zabbix_change_2.id change = CIChange( type=CI_CHANGE_TYPES.ZABBIX_TRIGGER, content_type=ContentType.objects.get_for_model(zabbix_change_2), object_id=self.zabbix_change_2_id, priority=CI_CHANGE_PRIORITY_TYPES.ERROR, ) change.save() self.not_touched_cichange_zabbix_id = change.id