def generate_data(self, data): for service in data['services'].values(): for env in data['envs'].values(): CIRelationFactory.create( parent=service, child=env, type=CI_RELATION_TYPES.CONTAINS, )
def generate_data(self, data): business = BusinessLineFactory(name='IT') profit_center = ProfitCenterFactory(name='Default profit center') CIRelationFactory.create( parent=business, child=profit_center, type=CI_RELATION_TYPES.CONTAINS, ) for service in data['services'].values(): CIRelationFactory.create( parent=profit_center, child=service, type=CI_RELATION_TYPES.CONTAINS, )
def setUp(self): self.client = login_as_su(is_superuser=True) self.category_blade = AssetCategory.objects.get(name='Server Blade') self.category_non_blade = AssetCategory.objects.get(name='Server Rack') self.model_blade = AssetModelFactory(category=self.category_blade) self.model_none_blade = AssetModelFactory( category=self.category_non_blade, ) self.warehouse = WarehouseFactory() self.ci_relation = CIRelationFactory()
def device_environment(self, create, extracted, **kwargs): if not create: # Simple build, do nothing. return if extracted: self.device_environment = extracted else: if self.service: ci_relation = CIRelationFactory(parent=self.service) self.device_environment = ci_relation.child
def setUp(self): self.client = login_as_su() self.warehouse = WarehouseFactory() self.category = AssetCategoryFactory() self.model = AssetModelFactory(category=self.category) self.addform = '/assets/dc/add/device/' ci_relation = CIRelationFactory() self.common_test_data = dict( asset=True, deprecation_rate=0, device_environment=ci_relation.child.id, invoice_date='2001-01-02', model=self.model.id, price='10', production_year=2011, ralph_device_id='', service=ci_relation.parent.id, size=1, slots=1, source=1, status=AssetStatus.new.id, type=AssetType.data_center.id, warehouse=self.warehouse.id, )
def test_getting_environments(self): service = ServiceCatalogFactory() env = DeviceEnvironmentFactory() self.assertEqual(len(service.get_environments()), 0) CIRelationFactory(parent=service, child=env) self.assertEqual(len(service.get_environments()), 1)