class Params: mine = factory.SubFactory('tests.factories.MineFactory', minimal=True) inspector = factory.SubFactory( 'tests.factories.PartyBusinessRoleFactory') approved = factory.Trait( variance_application_status_code='APP', issue_date=TODAY, expiry_date=TODAY, inspector_party_guid=factory.SelfAttribute('inspector.party_guid')) denied = factory.Trait( variance_application_status_code='DEN', inspector_party_guid=factory.SelfAttribute('inspector.party_guid')) not_applicable = factory.Trait(variance_application_status_code='NAP')
class Params: male = factory.Trait( first_name=factory.Faker("first_name_male"), middle_name=factory.Faker("first_name_male"), preferred_name=factory.Faker("first_name_male"), gender="M", ) female = factory.Trait( first_name=factory.Faker("first_name_female"), middle_name=factory.Faker("first_name_female"), preferred_name=factory.Faker("first_name_female"), gender="F", )
class Params: flag_is_superuser = factory.Trait( is_superuser=True, is_staff=True, username=factory.Sequence(lambda n: "admin%d" % n), password="******", ) flag_is_staff = factory.Trait( is_staff=True, username=factory.Sequence(lambda n: "staff%d" % n), password="******", )
class Params: is_zaak = factory.Trait( object_type=ObjectTypes.zaak, object=factory.Sequence( lambda n: f'https://zrc.nl/api/v1/zaken/{n}'), registratiedatum=factory.Faker('past_datetime', tzinfo=timezone.utc), aard_relatie=RelatieAarden.hoort_bij) is_besluit = factory.Trait( object_type=ObjectTypes.besluit, object=factory.Sequence( lambda n: f'https://brc.nl/api/v1/besluiten/{n}'), aard_relatie=RelatieAarden.legt_vast)
class Params: person = factory.Trait( first_name=factory.Faker('first_name'), party_name=factory.Faker('last_name'), email=factory.LazyAttribute(lambda o: f'{o.first_name}.{o.party_name}@example.com'), party_type_code='PER', ) company = factory.Trait( party_name=factory.Faker('company'), email=factory.Faker('company_email'), party_type_code='ORG', )
class Params: """ Declare traits that add relevant parameters for admin and superuser """ flag_is_admin = factory.Trait( is_superuser=False, is_staff=True, username=factory.Sequence(lambda n: "admin-%d" % n), ) flag_is_superuser = factory.Trait( is_superuser=True, is_staff=True, username=factory.Sequence(lambda n: "superuser-%d" % n), )
class Params: # this trait denotes what a comment that hasn't had data populated from reddit looks like unpopulated = factory.Trait( title=None, url=None, text=None, author=None, edited=None, removed=None, deleted=None, ) is_link = factory.Trait(post_type=LINK_TYPE_LINK) is_text = factory.Trait(post_type=LINK_TYPE_SELF) is_article = factory.Trait(post_type=EXTENDED_POST_TYPE_ARTICLE)
class Params: github = factory.Trait(provider='github', scopes=['user:email', 'read:org', 'repo'], config={ 'access_token': 'access-token', 'refresh_token': 'refresh-token', 'login': '******', }) github_barebones = factory.Trait(provider='github', scopes=['user:email', 'read:org'], config={ 'access_token': 'access-token', 'refresh_token': 'refresh-token', 'login': '******', })
class Params: # See # https://factoryboy.readthedocs.io/en/latest/reference.html#factory.Trait ix = factory.Trait( # SubFactory should be given as an absolute string because # it's not declared yet contacts_map__ix=factory.SelfAttribute('ix'))
class Params: includes_today = factory.Trait( active_during=interval.closedopen( datetime.now(timezone.utc) - timedelta(1), datetime.now(timezone.utc) + timedelta(1), ), )
class Params: associated_with_measure = factory.Trait( footnoteassociationmeasure=related_factory( "common.tests.factories.FootnoteAssociationMeasureFactory", factory_related_name="associated_footnote", ), ) associated_with_goods_nomenclature = factory.Trait( footnoteassociationgoodsnomenclature=related_factory( "common.tests.factories.FootnoteAssociationGoodsNomenclatureFactory", factory_related_name="associated_footnote", ), ) associated_with_additional_code = factory.Trait( footnoteassociationadditionalcode=related_factory( "common.tests.factories.FootnoteAssociationAdditionalCodeFactory", factory_related_name="associated_footnote", ), )
class Params: """Params for modifying the factory's default attributes.""" year = TODAY.year # A lot of functionality depends on future matches for generating predictions future = factory.Trait(start_date_time=factory.LazyAttributeSequence( _fake_future_datetime))
class Params: password = "******" #: Trait for creating admin users admin = factory.Trait( groups=factory.LazyAttribute(lambda obj: [ensure_admin_group_returned()]), )
class Params: external = factory.Trait( attributed_to=factory.LazyFunction(actors.get_service_actor), library__privacy_level="me", actor=factory.SubFactory( federation_factories.ActorFactory, local=True, preferred_username=factory.LazyFunction(get_rss_channel_name), ), ) local = factory.Trait( attributed_to=factory.SubFactory(federation_factories.ActorFactory, local=True), library__privacy_level="everyone", artist__local=True, )
class Params: round = factory.SubFactory(RoundPageFactory, start_from='internannounce') signed = factory.Trait( intern_contract=factory.SubFactory(SignedContractFactory)) active = factory.Trait( # checked by home.views.intern_in_good_standing() organizer_approved=True, in_good_standing=True, # but these also ought to be set signed=True, #mentors=1, # the post_generation function is not called if this is set )
class Params: in_diff = factory.Trait( diff_lines_covered=factory. LazyAttribute(lambda o: max(o.lines_covered - randint(0, 3), 0)), diff_lines_uncovered=factory. LazyAttribute(lambda o: max(o.lines_covered - randint(0, 5), 0)), )
class Params: expired = factory.Trait( token_expires_at=factory.LazyFunction( lambda: FAKE.date_time_this_year( before_now=True, after_now=False, tzinfo=pytz.utc ) ) )
class Params: github = factory.Trait( provider=models.RepositoryProvider.github, external_id=factory.LazyAttribute( lambda o: "{}/{}".format(o.owner_name, o.name)), data=factory.LazyAttribute( lambda o: {"full_name": "{}/{}".format(o.owner_name, o.name)}), )
class Params: # Allow us to quickly enable staff/superuser flags superuser = factory.Trait( is_superuser=True, is_staff=True, ) # Meta parameter handling all 'enabled'-related fields enabled = True
class Params: inactive = factory.Trait(activation=factory.SubFactory(Activation)) # A count that's appended to non-unique usernames to make them unique. count = factory.Sequence(lambda n: "%d" % n) # The non-unique part of the generated username. non_unique_username = factory.Faker("user_name") # The domain (following ``@``) part of the generated email address. email_domain = factory.Faker("free_email_domain")
class Params: with_answers = factory.Trait( questions=factory.RelatedFactoryList( 'question.tests.factories.AnswerFactory', factory_related_name='question', size=2, ) )
class Params: with_footnote = factory.Trait(association=factory.RelatedFactory( "common.tests.factories.FootnoteAssociationMeasureFactory", transaction=factory.SelfAttribute("..transaction"), factory_related_name="footnoted_measure", ), ) with_exclusion = factory.Trait(exclusion=factory.RelatedFactory( "common.tests.factories.MeasureExcludedGeographicalAreaFactory", transaction=factory.SelfAttribute("..transaction"), factory_related_name="modified_measure", ), ) with_condition = factory.Trait(condition=factory.RelatedFactory( "common.tests.factories.MeasureConditionFactory", transaction=factory.SelfAttribute("..transaction"), factory_related_name="dependent_measure", ), )
class Params: counter = "Adder not set" matching_account = factory.Trait( account=factory.SubFactory( AccountFactory, name=factory.SelfAttribute("..Account1_Name__c"), BillingStreet=factory.SelfAttribute("..Account1_Street__c"), BillingCountry=factory.SelfAttribute("..Account1_Country__c"), description="Pre-existing" ) ) matching_contact = factory.Trait( contact=factory.SubFactory( ContactFactory, name=factory.SelfAttribute("..Contact1_Lastname__c"), description="Pre-existing" ) )
class Params: temp_name = factory.Sequence(lambda n: "field_%d" % n) temp_dtype = common.DataType.INT64 temp_init = factory.Trait( left=factory.LazyAttribute( lambda obj: npir.VectorTemp(name=obj.temp_name)), right=factory.LazyAttribute( lambda obj: npir.EmptyTemp(dtype=obj.temp_dtype)), )
class Params: """ Params for modifying the factory's default attributes. Params: ------- force_correct: A factory trait that, when present, forces the predicted_winner to equal the actual match winner. We sometimes need this for tests that check prediction metric calculations. """ force_correct = factory.Trait(predicted_winner=factory.LazyAttribute( lambda pred: max(pred.match.teammatch_set.all(), key=lambda pred: pred.score).team)) force_incorrect = factory.Trait(predicted_winner=factory.LazyAttribute( lambda pred: min(pred.match.teammatch_set.all(), key=lambda pred: pred.score).team))
class Params: closed = factory.Trait( einddatum=factory.LazyFunction(date.today), status_set=factory.RelatedFactory( "openzaak.components.zaken.tests.factories.StatusFactory", factory_related_name="zaak", statustype__zaaktype=factory.SelfAttribute("..zaak.zaaktype"), ), )
class Params: minimal = factory.Trait(mine_no=None, mine_note=None, mine_region='NE', latitude=None, longitude=None, geom=None, mine_location_description=None, mine_type=None, verified_status=None, mine_status=None, mine_tailings_storage_facilities=0, mine_permit=0, mine_incidents=0, mine_variance=0, mine_reports=0) operating = factory.Trait(mine_status=factory.RelatedFactory( MineStatusFactory, 'mine', operating=True))
class Params: no_failures = factory.Trait( live=True, result_last_seen=datetime.today(), forces_https=True, hsts=True, hsts_max_age=True, hsts_entire_domain=True, hsts_preloaded=True, http_status_200_ok=True, no_cross_domain_redirects=True, no_cross_domain_assets=True, expected_encoding=True, no_server_info=True, no_server_version=True, csp_origin_only=True, mime_sniffing_blocked=True, noopen_download=True, xss_protection=True, clickjacking_protection=True, good_cross_domain_policy=True, http_1_0_caching_disabled=True, cache_control_set=True, cache_control_revalidate_set=True, cache_control_nocache_set=True, cache_control_notransform_set=True, cache_control_nostore_set=True, cache_control_private_set=True, expires_set=True, referrer_policy_set_to_no_referrer=True, safe_onion_address=True, no_cdn=True, no_analytics=True, subdomain=False, no_cookies=True, ) moderate_warning = factory.Trait( no_failures=True, safe_onion_address=False, ) severe_warning = factory.Trait( no_failures=True, no_analytics=False, )
class Params: github = factory.Trait( provider="github", scopes=["user:email", "read:org", "repo"], config={ "access_token": "access-token", "refresh_token": "refresh-token", "login": "******", }, ) github_barebones = factory.Trait( provider="github", scopes=["user:email", "read:org"], config={ "access_token": "access-token", "refresh_token": "refresh-token", "login": "******", }, )
class Params: github = factory.Trait( provider=models.RepositoryProvider.github, external_id=factory.LazyAttribute( lambda o: '{}/{}'.format(o.owner_name, o.name)), data=factory.LazyAttribute(lambda o: ({ 'github': { 'full_name': '{}/{}'.format(o.owner_name, o.name) } })))