class TemperatureResponseFactory(CleanModelFactory): class Meta(object): model = TemperatureResponse request = factory.SubFactory(TeamTemperatureFactory) responder = factory.SubFactory(UserFactory) score = FuzzyInteger(1, 10) word = FuzzyText(length=random.randint(2, 32), chars=(string.ascii_letters + '-')) response_date = factory.LazyFunction(timezone.now) team_name = FuzzyText(length=random.randint(1, 64), chars=(utils.chars + '_-'))
class PlaceholderFactory(factory.django.DjangoModelFactory): default_width = FuzzyInteger(0, 25) slot = 'content' object_id = factory.SelfAttribute("source.id") content_type = factory.LazyAttribute( lambda o: ContentType.objects.get_for_model(o.source)) # this can take other types of content as well, but putting in # versioned PageContent by default source = factory.SubFactory(PageContentWithVersionFactory) class Meta: model = Placeholder
class PullRequestPayloadFactory(Factory): """ Payload representation of the state of a pull request. https://developer.github.com/v3/pulls/#get-a-single-pull-request Args: id (int, optional): GitHub's internal ID for this PR. number (int, optional): GitHub's friendly number for the PR. state (str, optional): Either 'open' or 'closed'. commits_url (str, optional): URL on the GitHub API to collect the commits in this PR. commits (int, optional): Number of commits in this PR. """ class Meta: model = dict id = FuzzyInteger(low=1000, high=999999999) number = FuzzyInteger(low=1, high=1000) state = FuzzyChoice(('open', 'closed')) commits_url = 'http://TODO' commits = FuzzyInteger(low=1, high=20)
class SafeLastStatusFactory(DjangoModelFactory): class Meta: model = SafeLastStatus internal_tx = factory.SubFactory(InternalTxFactory) address = factory.LazyFunction(lambda: Account.create().address) owners = factory.LazyFunction(lambda: [Account.create().address for _ in range(4)]) threshold = FuzzyInteger(low=1, high=2) nonce = factory.Sequence(lambda n: n) master_copy = factory.LazyFunction(lambda: Account.create().address) fallback_handler = NULL_ADDRESS guard = NULL_ADDRESS enabled_modules = []
class CourseRunFactory(factory.DjangoModelFactory): course = factory.SubFactory(CourseFactory) start = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=UTC)) end = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=UTC)).end_dt enrollment_start = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=UTC)) enrollment_end = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=UTC)).end_dt certificate_generation = FuzzyDateTime(datetime(2014, 1, 1, tzinfo=UTC)) min_effort = FuzzyInteger(1, 10) max_effort = FuzzyInteger(10, 20) language = factory.Iterator(LanguageTag.objects.all()) pacing_type = FuzzyChoice([name for name, __ in CourseRunPacing.choices]) length = FuzzyInteger(1, 10) notes = "Testing notes" preview_url = FuzzyText(prefix='https://example.com/') contacted_partner_manager = FuzzyChoice((True, False)) video_language = factory.Iterator(LanguageTag.objects.all()) short_description_override = FuzzyText() title_override = FuzzyText() full_description_override = FuzzyText() class Meta: model = CourseRun
class PatientFactory(DjangoModelFactory): """ Fabrica o crea un objeto Paciente de prueba """ class Meta: model = Patient full_name = factory.Faker('name') dni = FuzzyInteger(10000000, 99999999) gender = factory.Iterator( [Patient.Gender.MALE, Patient.Gender.FEMALE, Patient.Gender.OTHER]) phone = factory.Faker('phone_number') job = factory.Faker('job')
class TeamResponseHistoryFactory(CleanModelFactory): class Meta(object): model = TeamResponseHistory request = factory.SubFactory(TeamTemperatureFactory) average_score = FuzzyDecimal(1, 10, 5) responder_count = FuzzyInteger(1, 25) team_name = FuzzyText(length=random.randint(1, 64), chars=(utils.chars + '_-')) archive_date = factory.LazyFunction(timezone.now) @factory.lazy_attribute def word_list(self): return fake.words(nb=self.responder_count)