factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

Feature/Add FireO support

Open ADR-007 opened this issue 2 years ago • 1 comments

Add supporting for FireO (ORM for Firestore)

Example:

from fireo import Model
from factory_boy.fireo import FireoAutoFactory, nullable

class Comment(Model):
    text = fields.TextField()

class User(Model):
    name = fields.TextField()
    email = MyCustomEmailField()
    comments = fields.ListField(Comment)

class UserFactory(FireoAutoFactory):
    class Meta:
        model = User
        extra_mapping = {
            MyCustomEmailField: lambda maker, field: nullable(field, factory.Faker('email')),
        }

model = UserFactory.create()
assert model.name
assert model.email # works for custom fields too
assert model.comments[0].text  # works for nested models too

ADR-007 avatar Mar 03 '23 16:03 ADR-007

Hi there!

I already have an updated version of it. Please let me know if we can merge it, so I'll know if I need to update the PR.

Thank you!

ADR-007 avatar Mar 15 '23 17:03 ADR-007