import factory.fuzzy
import faker
from core.strings import underscore_15
from factory import DjangoModelFactory, SubFactory
faker = faker.Factory.create()
class SubProjectFactory(DjangoModelFactory):
class Meta:
model = SubProject
django_get_or_create = ("internal_name",)
internal_name = factory.Faker('pystr')
internal_short_name = factory.Faker('pystr')
underscore_15 = factory.fuzzy.FuzzyText(length=15)
main_project = SubFactory(MainProjectFactory)
I need the field underscore_15 to be a lower-case string of specifically just 15 characters long and no spaces. If there's any space it should be underscore. I tried to put a function around factory.fuzzy.FuzzyText(length=15)
. Then I realized that I was assuming FuzzyText returns a string but it was a FuzzyText object.
What should I do?