Python factory.Sequence() Examples

The following are 4 code examples of factory.Sequence(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module factory , or try the search function .
Example #1
Source File: model_factories.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def UssdSessionFactory(**kwargs):
    # Uses Class Naming Convention because it's actually a delayed execution Class
    def inner():
        unique_name = Sequence(lambda n: f'FooSSD{n}')
        ussd_menu = UssdMenuFactory(name=unique_name, display_key=unique_name)

        return UssdSessionFactoryBase(ussd_menu=ussd_menu, **kwargs)

    return inner() 
Example #2
Source File: tweet.py    From busy-beaver with MIT License 5 votes vote down vote up
def Tweet(session):
    class _TweetFactory(factory.Factory):
        class Meta:
            model = model

        id = factory.Sequence(lambda n: n)

    return _TweetFactory 
Example #3
Source File: pytest_fixtures.py    From silver with Apache License 2.0 5 votes vote down vote up
def two_pages_of_invoices(db, settings):
    allowed_states = [Invoice.STATES.ISSUED, Invoice.STATES.PAID, Invoice.STATES.CANCELED]
    return InvoiceFactory.create_batch(
        settings.API_PAGE_SIZE * 2,
        state=factory.Sequence(
            lambda n: allowed_states[n % len(allowed_states)]
        )
    ) 
Example #4
Source File: bcc_factories.py    From trinity with MIT License 5 votes vote down vote up
def create_branch_by_slots(
        cls, slots: Sequence[Slot], root: BaseSignedBeaconBlock = None, **kwargs: Any
    ) -> Iterable[BaseSignedBeaconBlock]:
        if root is None:
            root = cls()

        parent = cls(
            message__parent_root=root.message.hash_tree_root, message__slot=slots[0], **kwargs
        )
        yield parent
        for slot in slots[1:]:
            child = cls(message__parent_root=parent.message.hash_tree_root, message__slot=slot)
            yield child
            parent = child