本文整理匯總了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)