octabytes / FireO

Google Cloud Firestore modern and simplest convenient ORM package in Python. FireO is specifically designed for the Google's Firestore
https://fireo.octabyte.io
Apache License 2.0
250 stars 30 forks source link

FactoryBoy factories are coming soon! #187

Open ADR-007 opened 1 year ago

ADR-007 commented 1 year ago

I did PR with FireoFactory and FireoAutoFactory. I hope it will be available soon :) Please add likes to the PR if you want to see the changes in FactoryBoy sooner :)

Usage 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
AxeemHaider commented 1 year ago

I really appreciate your work, you are doing great. Somehow we have also update Docs So, other also knows what you have done :)

ADR-007 commented 1 year ago

Yes, I have a list with updates in the documentation I need to do. I hope to do it soon :)