當前位置: 首頁>>代碼示例>>Python>>正文


Python factory.SubFactory方法代碼示例

本文整理匯總了Python中factory.SubFactory方法的典型用法代碼示例。如果您正苦於以下問題:Python factory.SubFactory方法的具體用法?Python factory.SubFactory怎麽用?Python factory.SubFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在factory的用法示例。


在下文中一共展示了factory.SubFactory方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GitHubSummaryUser

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def GitHubSummaryUser(session):
    class _GitHubSummaryUserFactory(factory.alchemy.SQLAlchemyModelFactory):
        class Meta:
            model = github_summary_user_model
            sqlalchemy_session_persistence = "commit"
            sqlalchemy_session = session

        slack_id = "slack_user"
        github_id = "13242345435"
        github_username = "github_user"
        github_state = ""
        github_access_token = factory.Faker("uuid4")
        configuration = factory.SubFactory(GitHubSummaryConfiguration(session))

    return _GitHubSummaryUserFactory 
開發者ID:busy-beaver-dev,項目名稱:busy-beaver,代碼行數:17,代碼來源:github_summary_user.py

示例2: GitHubSummaryConfiguration

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def GitHubSummaryConfiguration(session):
    class _GitHubSummaryConfiguration(factory.alchemy.SQLAlchemyModelFactory):
        class Meta:
            model = github_summary_configuration_model
            sqlalchemy_session_persistence = "commit"
            sqlalchemy_session = session

        channel = "busy-beaver"
        time_to_post = "2:00pm"
        timezone_info = {}
        slack_installation = factory.SubFactory(SlackInstallation(session))

    return _GitHubSummaryConfiguration 
開發者ID:busy-beaver-dev,項目名稱:busy-beaver,代碼行數:15,代碼來源:github_summary_user.py

示例3: SlackUser

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def SlackUser(session):
    class _SlackUserFactory(factory.alchemy.SQLAlchemyModelFactory):
        class Meta:
            model = slack_user_model
            sqlalchemy_session_persistence = "commit"
            sqlalchemy_session = session

        installation = factory.SubFactory(SlackInstallation(session))
        slack_id = "user_id"

    return _SlackUserFactory 
開發者ID:busy-beaver-dev,項目名稱:busy-beaver,代碼行數:13,代碼來源:slack.py

示例4: moderators

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def moderators(self, create, extracted, **kwargs):
        if not extracted:
            user_factory = factory.SubFactory(USER_FACTORY).get_factory()
            self.moderators.add(user_factory())
            return

        if extracted:
            for user in extracted:
                self.moderators.add(user) 
開發者ID:liqd,項目名稱:adhocracy4,代碼行數:11,代碼來源:__init__.py

示例5: __new__

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def __new__(mcs, class_name, bases, attrs):
        # Add the form field definitions to allow nested calls
        field_factory = attrs.pop('field_factory', None)
        if field_factory:
            wrapped_factories = {
                k: factory.SubFactory(AnswerFactory, sub_factory=v)
                for k, v in field_factory.factories.items()
                if issubclass(v, FormFieldBlockFactory)
            }
            attrs.update(wrapped_factories)
        return super().__new__(mcs, class_name, bases, attrs) 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:13,代碼來源:factories.py

示例6: _create

# 需要導入模塊: import factory [as 別名]
# 或者: from factory import SubFactory [as 別名]
def _create(cls, model_class, *args, **kwargs):
        """ Create a corresponding user whenever we make a Participant.

        Each Participant stores the ID of its user, but it's not truly a
        foreign key, since the row resides in another database. Accordingly,
        we cannot use a SubFactory for the User object.
        """
        if not kwargs.pop('_disable_auto_user_creation', False):
            user = UserFactory.create(email=kwargs['email'])
            kwargs['user_id'] = user.pk

        return super()._create(model_class, *args, **kwargs) 
開發者ID:DavidCain,項目名稱:mitoc-trips,代碼行數:14,代碼來源:factories.py


注:本文中的factory.SubFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。