本文整理汇总了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
示例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
示例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
示例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)
示例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)
示例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)