Python factory.SubFactory() Examples
The following are 6
code examples of factory.SubFactory().
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: github_summary_user.py From busy-beaver with MIT License | 5 votes |
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
Example #2
Source File: github_summary_user.py From busy-beaver with MIT License | 5 votes |
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
Example #3
Source File: slack.py From busy-beaver with MIT License | 5 votes |
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
Example #4
Source File: __init__.py From adhocracy4 with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #5
Source File: factories.py From hypha with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #6
Source File: factories.py From mitoc-trips with GNU General Public License v3.0 | 5 votes |
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)