def test_create_missing_support_offerings_with_offering_plan(self): offering = support_factories.OfferingFactory() category = marketplace_factories.CategoryFactory() customer = structure_factories.CustomerFactory() offering_plan = support_factories.OfferingPlanFactory(template=offering.template, unit_price=offering.unit_price) marketplace_support_utils.init_offerings_and_resources(category, customer) self.assertTrue(marketplace_models.Plan.objects.filter(scope=offering_plan).exists()) self.assertEqual(marketplace_models.Plan.objects.count(), 1) self.assertTrue(marketplace_models.Resource.objects.filter(scope=offering).exists())
def setUp(self): self.provider = marketplace_factories.ServiceProviderFactory() self.provider_2 = marketplace_factories.ServiceProviderFactory() self.offering = marketplace_factories.OfferingFactory( type=PACKAGE_TYPE, customer=self.provider.customer) self.offering_component = marketplace_factories.OfferingComponentFactory( offering=self.offering) self.plan = marketplace_factories.PlanFactory( offering=self.offering, unit=UnitPriceMixin.Units.PER_DAY, ) self.component = marketplace_factories.PlanComponentFactory( component=self.offering_component, price=Decimal(5), plan=self.plan) self.offering_2 = marketplace_factories.OfferingFactory( type=PACKAGE_TYPE, customer=self.provider_2.customer) self.offering_component_2 = marketplace_factories.OfferingComponentFactory( offering=self.offering_2) self.plan_2 = marketplace_factories.PlanFactory( offering=self.offering_2, unit=UnitPriceMixin.Units.PER_DAY, ) self.component_2 = marketplace_factories.PlanComponentFactory( component=self.offering_component_2, price=Decimal(7), plan=self.plan_2) self.resource_1 = marketplace_factories.ResourceFactory( state=marketplace_models.Resource.States.OK, offering=self.offering, plan=self.plan, limits={'cpu': 1}, ) self.resource_2 = marketplace_factories.ResourceFactory( state=marketplace_models.Resource.States.OK, offering=self.offering, project=self.resource_1.project, plan=self.plan, limits={'cpu': 1}, ) self.resource_3 = marketplace_factories.ResourceFactory( state=marketplace_models.Resource.States.OK, offering=self.offering_2, project=self.resource_1.project, plan=self.plan_2, limits={'cpu': 1}, ) self.customer = self.resource_1.project.customer self.support_template = support_factories.OfferingTemplateFactory() self.support_plan = support_factories.OfferingPlanFactory( template=self.support_template, unit_price=7, ) self.support_offering = support_factories.OfferingFactory( project=self.resource_1.project, template=self.support_template, plan=self.support_plan, state=support_models.Offering.States.OK, )