Esempio n. 1
0
class BackendNetworkFactory(factory.DjangoModelFactory):
    FACTORY_FOR = models.BackendNetwork

    network = factory.SubFactory(NetworkFactory, state="ACTIVE")
    backend = factory.SubFactory(BackendFactory)
    operstate = factory.Sequence(round_seq_first(FACTORY_FOR.OPER_STATES))
Esempio n. 2
0
class BookingErrorFactory(factory.DjangoModelFactory):
    """ Factory for the ``BookingError`` model. """
    class Meta:
        model = models.BookingError

    booking = factory.SubFactory(BookingFactory)
Esempio n. 3
0
class UserImageFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = UserImage

    user = factory.SubFactory(CustomUserFactory)
    image = factory.django.ImageField(file_name='test_image.jpg')
Esempio n. 4
0
class TopicPollVoteFactory(factory.DjangoModelFactory):
    poll_option = factory.SubFactory(TopicPollOptionFactory)
    voter = factory.SubFactory(UserFactory)

    class Meta:
        model = TopicPollVote
class AuthorBioFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = AuthorBio

    author = factory.SubFactory(AuthorFactory)
    body = factory.LazyAttribute(lambda x: faker.text())
Esempio n. 6
0
class UserLogFactory(BaseFactory):
    class Meta:
        model = demoapp.UserLog

    message = factory.fuzzy.FuzzyText()
    user = factory.SubFactory(UserFactory)
Esempio n. 7
0
class TopicPollFactory(factory.DjangoModelFactory):
    topic = factory.SubFactory(TopicFactory)
    question = faker.text(max_nb_chars=200)

    class Meta:
        model = TopicPoll
Esempio n. 8
0
class CollectionMemberFactory(DjangoModelFactory):
    collection = factory.SubFactory(CollectionFactory, parent=None)
Esempio n. 9
0
class PlanScheduleFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = PlanSchedule

    branch = factory.SubFactory(BranchFactory)
    plan = factory.SubFactory(PlanFactory)
Esempio n. 10
0
class LessonFactory(factory.DjangoModelFactory):
    class Meta:
        model = Lesson

    course = factory.SubFactory(CourseFactory)
    start_time = ru_faker('date_time')
Esempio n. 11
0
class IndustryTagFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = snippets.IndustryTag

    name = factory.fuzzy.FuzzyText(length=10)
    icon = factory.SubFactory(wagtail_factories.ImageFactory)
Esempio n. 12
0
class TeacherFactory(factory.DjangoModelFactory):
    class Meta:
        model = Teacher

    user = factory.SubFactory(UserFactory)
Esempio n. 13
0
class ProjectBackendFactory(factory.DjangoModelFactory):
    FACTORY_FOR = models.ProjectBackend

    project = factory.Sequence(prefix_seq("project"))
    backend = factory.SubFactory(BackendFactory)
Esempio n. 14
0
class FloatingIPFactory(IPv4AddressFactory):
    network = factory.SubFactory(NetworkFactory,
                                 public=True,
                                 floating_ip_pool=True,
                                 state="ACTIVE")
    floating_ip = True
Esempio n. 15
0
class PlantationFactory(factory.django.DjangoModelFactory):
    name = factory.fuzzy.FuzzyText()
    geo_location = factory.SubFactory(GeolocationFactory)

    class Meta:
        model = PlantationModel
Esempio n. 16
0
class OrgFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Org

    repo = factory.SubFactory(RepositoryFactory)
    json = "{}"
Esempio n. 17
0
class FavoriteProductFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = FavoriteProduct

    customer = factory.SubFactory(CustomerFactory)
    product = factory.SubFactory(ProductFactory)
Esempio n. 18
0
class ScratchOrgInstanceFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ScratchOrgInstance

    org = factory.SubFactory(OrgFactory)
Esempio n. 19
0
class TaggedItemFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = TaggedItem

    content_object = factory.SubFactory(EntryFactory)
    tag = factory.LazyAttribute(lambda x: faker.word())
Esempio n. 20
0
class PlanRepositoryFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = PlanRepository

    plan = factory.SubFactory(PlanFactory)
    repo = factory.SubFactory(RepositoryFactory)
Esempio n. 21
0
class TopicPollOptionFactory(factory.DjangoModelFactory):
    poll = factory.SubFactory(TopicPollFactory)
    text = faker.text(max_nb_chars=100)

    class Meta:
        model = TopicPollOption
Esempio n. 22
0
class BranchFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Branch

    name = factory.fuzzy.FuzzyChoice(["master", "branch1", "branch2"])
    repo = factory.SubFactory(RepositoryFactory)
class TaxSubFactory(TaxFactoryBase):
    event = factory.SubFactory(EventFactoryBasic)
Esempio n. 24
0
class BlogPostVersionFactory(AbstractVersionFactory):
    content = factory.SubFactory(BlogContentFactory)

    class Meta:
        model = Version
Esempio n. 25
0
class ProfileFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Profile

    user = factory.SubFactory(UserFactory, profile=None)
Esempio n. 26
0
class PageFactory(factory.django.DjangoModelFactory):
    node = factory.SubFactory(TreeNodeFactory)

    class Meta:
        model = Page
Esempio n. 27
0
class ExperimentFactory(factory.django.DjangoModelFactory):
    type = Experiment.TYPE_PREF
    owner = factory.SubFactory(UserFactory)
    project = factory.SubFactory(ProjectFactory)
    name = factory.LazyAttribute(lambda o: faker.catch_phrase())
    slug = factory.LazyAttribute(lambda o: "{}_".format(slugify(o.name)))
    archived = False
    short_description = factory.LazyAttribute(
        lambda o: faker.text(random.randint(100, 500)))
    proposed_start_date = factory.LazyAttribute(lambda o: (datetime.date.today(
    ) + datetime.timedelta(days=random.randint(1, 10))))
    proposed_end_date = factory.LazyAttribute(
        lambda o: (o.proposed_start_date + datetime.timedelta(days=random.
                                                              randint(1, 10))))
    pref_key = factory.LazyAttribute(lambda o: "browser.{pref}.enabled".format(
        pref=faker.catch_phrase().replace(" ", ".").lower()))
    pref_type = factory.LazyAttribute(
        lambda o: random.choice(Experiment.PREF_TYPE_CHOICES[1:])[0])
    pref_branch = factory.LazyAttribute(
        lambda o: random.choice(Experiment.PREF_BRANCH_CHOICES[1:])[0])
    firefox_version = factory.LazyAttribute(
        lambda o: random.choice(Experiment.VERSION_CHOICES[1:])[0])
    firefox_channel = factory.LazyAttribute(
        lambda o: random.choice(Experiment.CHANNEL_CHOICES[1:])[0])
    objectives = factory.LazyAttribute(
        lambda o: faker.text(random.randint(500, 5000)))
    analysis_owner = factory.LazyAttribute(lambda o: faker.name())
    analysis = factory.LazyAttribute(
        lambda o: faker.text(random.randint(500, 5000)))
    testing = factory.LazyAttribute(
        lambda o: faker.text(random.randint(500, 5000)))
    risks = factory.LazyAttribute(
        lambda o: faker.text(random.randint(500, 5000)))
    total_users = factory.LazyAttribute(
        lambda o: random.randint(100000, 1000000))
    risk_partner_related = False
    risk_brand = False
    risk_fast_shipped = False
    risk_confidential = False
    risk_release_population = False
    enrollment_dashboard_url = "http://www.example.com/enrollment"
    dashboard_url = "http://www.example.com/dashboard"
    dashboard_image_url = "http://www.example.com/dashboard.png"
    population_percent = factory.LazyAttribute(
        lambda o: decimal.Decimal(random.randint(1, 10) * 10))
    client_matching = ("Locales: en-US, en-CA, en-GB\nGeos: US, CA, GB\n"
                       'Some "additional" filtering')
    review_phd = False
    review_science = False
    review_peer = False
    review_relman = False
    review_qa = False
    review_legal = False
    review_ux = False
    review_security = False
    review_vp = False
    review_data_steward = False

    class Meta:
        model = Experiment

    @classmethod
    def create_with_variants(cls, num_variants=3, *args, **kwargs):
        experiment = cls.create(*args, **kwargs)

        for i in range(num_variants):
            if i == 0:
                ExperimentControlFactory.create(experiment=experiment)
            else:
                ExperimentVariantFactory.create(experiment=experiment)

        return experiment

    @classmethod
    def create_with_status(cls, target_status, *args, **kwargs):
        experiment = cls.create_with_variants(*args, **kwargs)

        now = datetime.datetime.now() - datetime.timedelta(
            days=random.randint(100, 200))

        old_status = None
        for status_value, status_label in Experiment.STATUS_CHOICES:
            experiment.status = status_value
            experiment.save()

            change = ExperimentChangeLogFactory.create(
                experiment=experiment,
                old_status=old_status,
                new_status=status_value,
            )
            change.changed_on = now
            change.save()

            if status_value == target_status:
                break

            old_status = status_value
            now += datetime.timedelta(days=random.randint(5, 20))

        return experiment
Esempio n. 28
0
class PollVersionFactory(AbstractVersionFactory):
    content = factory.SubFactory(PollContentFactory)

    class Meta:
        model = Version
Esempio n. 29
0
class NotificationFactory(factory.django.DjangoModelFactory):
    user = factory.SubFactory(UserFactory)

    class Meta:
        model = "notifications.Notification"
Esempio n. 30
0
class VirtualMachineMetadataFactory(factory.DjangoModelFactory):
    FACTORY_FOR = models.VirtualMachineMetadata

    meta_key = factory.Sequence(prefix_seq('key'))
    meta_value = factory.Sequence(prefix_seq('pass'))
    vm = factory.SubFactory(VirtualMachineFactory)