Open
Description
Hi everyone! (Long time no talk)
I just came into the following situation that I can't seem to be able to untangle.
I have a "Product" model that is part of our core business logic, and a "Product" model coming in from Dj-stripe
When trying to set up the stripe models and relationships via the factories, I am running into a name collision
import factory
from djstripe.enums import SubscriptionStatus
from factory.django import DjangoModelFactory
from djstripe.models import (
Product as SubscriptionProduct,
Plan as SubscriptionPlan,
Customer as SubscriptionCustomer,
Price as SubscriptionPrice,
Subscription, SubscriptionItem
)
class SubscriptionProductFactory(DjangoModelFactory):
class Meta:
model = SubscriptionProduct
name = "Pro"
@classmethod
def _create(cls, model_class, *args, **kwargs):
product = super()._create(model_class, *args, **kwargs)
return product
class SubscriptionPriceFactory(DjangoModelFactory):
class Meta:
model = SubscriptionPrice
active = True
currency = "EUR"
unit_amount = 1000
product_test = factory.SubFactory("factories.stripe.SubscriptionProductFactory")
lookup_key = "pro_monthly"
@classmethod
def _create(cls, model_class, *args, **kwargs):
price = super()._create(model_class, *args, **kwargs)
return price
But when the SubscriptionProductFactory is used as a SubFactory, the inner factoryboy code is evaluating it's model.name
Which returns the fixture of the other Product model.
Since the original Product class is used everywhere, refactoring is not an option, and the model coming in from the external package is not possible to change.
Is there any solution for this?
Thanks
Metadata
Metadata
Assignees
Labels
No labels