Example #1
0
    def fuzz(self):
        root = FuzzyUrlRoot()
        resource = FuzzyText()

        return "{root}/{resource}".format(
            root=root.fuzz(),
            resource=resource.fuzz()
        )
Example #2
0
    def fuzz(self):
        subdomain = FuzzyText()
        domain = FuzzyText()
        tld = FuzzyChoice(('com', 'net', 'org', 'biz', 'pizza', 'coffee', 'diamonds', 'fail', 'win', 'wtf',))

        return "{subdomain}.{domain}.{tld}".format(
            subdomain=subdomain.fuzz(),
            domain=domain.fuzz(),
            tld=tld.fuzz()
        )
 def fuzz(self):
     protocol = FuzzyChoice(('http', 'https',))
     subdomain = FuzzyText()
     domain = FuzzyText()
     tld = FuzzyChoice(('com', 'net', 'org', 'biz', 'pizza', 'coffee', 'diamonds', 'fail', 'win', 'wtf',))
     resource = FuzzyText()
     return "{protocol}://{subdomain}.{domain}.{tld}/{resource}".format(
         protocol=protocol.fuzz(),
         subdomain=subdomain.fuzz(),
         domain=domain.fuzz(),
         tld=tld.fuzz(),
         resource=resource.fuzz()
     )
Example #4
0
class DegreeFactory(ProgramFactory):
    class Meta:
        model = Degree

    apply_url = FuzzyURL()
    overall_ranking = FuzzyText()
    lead_capture_list_name = FuzzyText()
    application_requirements = FuzzyText()
    prerequisite_coursework = FuzzyText()
    micromasters_url = FuzzyText()
    micromasters_long_title = FuzzyText()
    micromasters_long_description = FuzzyText()
    micromasters_org_name_override = FuzzyText()
    search_card_ranking = FuzzyText()
    search_card_cost = FuzzyText()
    search_card_courses = FuzzyText()
    banner_border_color = FuzzyText(length=6)

    @factory.post_generation
    def rankings(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.rankings, extracted)
Example #5
0
class ProgramFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Program

    title = factory.Sequence(lambda n: 'test-program-{}'.format(n))  # pylint: disable=unnecessary-lambda
    uuid = factory.LazyFunction(uuid4)
    subtitle = FuzzyText()
    marketing_hook = FuzzyText()
    type = factory.SubFactory(ProgramTypeFactory)
    status = ProgramStatus.Active
    marketing_slug = factory.Sequence(lambda n: 'test-slug-{}'.format(n))  # pylint: disable=unnecessary-lambda
    banner_image_url = FuzzyText(prefix='https://example.com/program/banner')
    card_image_url = FuzzyText(prefix='https://example.com/program/card')
    partner = factory.SubFactory(PartnerFactory)
    video = factory.SubFactory(VideoFactory)
    overview = FuzzyText()
    total_hours_of_effort = FuzzyInteger(2)
    weeks_to_complete = FuzzyInteger(1)
    min_hours_effort_per_week = FuzzyInteger(2)
    max_hours_effort_per_week = FuzzyInteger(4)
    credit_redemption_overview = FuzzyText()
    order_courses_by_start_date = True
    hidden = False

    @factory.post_generation
    def courses(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.courses, extracted)

    @factory.post_generation
    def excluded_course_runs(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.excluded_course_runs, extracted)

    @factory.post_generation
    def authoring_organizations(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.authoring_organizations, extracted)

    @factory.post_generation
    def corporate_endorsements(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.corporate_endorsements, extracted)

    @factory.post_generation
    def credit_backing_organizations(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.credit_backing_organizations, extracted)

    @factory.post_generation
    def expected_learning_items(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.expected_learning_items, extracted)

    @factory.post_generation
    def faq(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.faq, extracted)

    @factory.post_generation
    def individual_endorsements(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.individual_endorsements, extracted)

    @factory.post_generation
    def job_outlook_items(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.job_outlook_items, extracted)

    @factory.post_generation
    def instructor_ordering(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.instructor_ordering, extracted)

    @factory.post_generation
    def curricula(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.curricula, extracted)
Example #6
0
class ExpectedLearningItemFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = ExpectedLearningItem

    value = FuzzyText()
Example #7
0
class FAQFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = FAQ

    question = FuzzyText()
    answer = FuzzyText()
Example #8
0
class JobOutlookItemFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = JobOutlookItem

    value = FuzzyText()
Example #9
0
class LevelTypeFactory(AbstractNamedModelFactory):
    name_t = FuzzyText()

    class Meta:
        model = LevelType
Example #10
0
class AbstractTitleDescriptionFactory(factory.DjangoModelFactory):
    title = FuzzyText(length=255)
    description = FuzzyText()
Example #11
0
class AbstractNamedModelFactory(factory.DjangoModelFactory):
    name = FuzzyText()
Example #12
0
class CourseFactory(SalesforceRecordFactory):
    uuid = factory.LazyFunction(uuid4)
    key = FuzzyText(prefix='course-id/')
    key_for_reruns = FuzzyText(prefix='OrgX+')
    title = FuzzyText(prefix="Test çօմɾʂҽ ")
    short_description = FuzzyText(prefix="Test çօմɾʂҽ short description")
    full_description = FuzzyText(prefix="Test çօմɾʂҽ FULL description")
    level_type = factory.SubFactory(LevelTypeFactory)
    card_image_url = FuzzyURL()
    video = factory.SubFactory(VideoFactory)
    partner = factory.SubFactory(PartnerFactory)
    prerequisites_raw = FuzzyText()
    syllabus_raw = FuzzyText()
    outcome = FuzzyText()
    image = factory.django.ImageField()
    canonical_course_run = None
    extra_description = factory.SubFactory(AdditionalPromoAreaFactory)
    additional_information = FuzzyText()
    faq = FuzzyText()
    learner_testimonials = FuzzyText()
    type = factory.SubFactory(CourseTypeFactory)

    class Meta:
        model = Course

    @factory.post_generation
    def subjects(self, create, extracted, **kwargs):
        if create:  # pragma: no cover
            add_m2m_data(self.subjects, extracted)

    @factory.post_generation
    def authoring_organizations(self, create, extracted, **kwargs):
        if create:
            add_m2m_data(self.authoring_organizations, extracted)

    @factory.post_generation
    def sponsoring_organizations(self, create, extracted, **kwargs):
        if create:
            add_m2m_data(self.sponsoring_organizations, extracted)

    @factory.post_generation
    def url_slug_history(self, create, extracted, **kwargs):
        if create:
            data = {
                'is_active': True,
                'is_active_on_draft': True,
                'course': self,
                'partner': self.partner
            }
            if extracted:
                data.update(extracted)
            CourseUrlSlugFactory(**data)
Example #13
0
class AbstractMediaModelFactory(factory.DjangoModelFactory):
    src = FuzzyURL()
    description = FuzzyText()
Example #14
0
class ModeFactory(factory.DjangoModelFactory):
    name = FuzzyText()
    slug = FuzzyText()

    class Meta:
        model = Mode
Example #15
0
class RefreshTokenFactory(DjangoModelFactory):
    class Meta(object):
        model = RefreshToken
        django_get_or_create = ('user', 'application')

    token = FuzzyText(length=32)
Example #16
0
class EndorsementFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Endorsement

    endorser = factory.SubFactory(PersonFactory)
    quote = FuzzyText()
Example #17
0
class PersonAreaOfExpertiseFactory(factory.django.DjangoModelFactory):
    value = FuzzyText()
    person = factory.SubFactory(PersonFactory)

    class Meta:
        model = PersonAreaOfExpertise