Esempio n. 1
0
def random_feedback_data(
    *,
    name: str = None,
    email: str = None,
    company_name: str = None,
    country: str = None,
    comment: str = None,
    terms: str = None,
    g_recaptcha_response: str = None,
) -> Feedback:
    name = name or rare_word()
    email = email or f"test+buyer_{rare_word()}@{TEST_EMAIL_DOMAIN}"
    company_name = company_name or f"{rare_word()} AUTOTESTS"
    country = country or rare_word()
    comment = comment or sentence(max_length=1000)
    g_recaptcha_response = g_recaptcha_response or "test mode"
    terms = terms or "on"

    feedback = Feedback(
        name=name,
        email=email,
        company_name=company_name,
        country=country,
        comment=comment,
        terms=terms,
        g_recaptcha_response=g_recaptcha_response,
    )

    return feedback
Esempio n. 2
0
def test_search_supplier_200(basic_auth):
    sector = choice(SECTORS)
    url = URLs.FAS_SEARCH.absolute_template.format(query=rare_word(),
                                                   industries=sector)
    get_and_assert(url=url,
                   status_code=HTTP_200_OK,
                   auth=basic_auth,
                   allow_redirects=True)
Esempio n. 3
0
def random_case_study_data(alias: str) -> CaseStudy:
    """Return a CaseStudy populated with randomly generated details.

    :param alias: alias of the Case Study
    :return: a CaseStudy namedtuple
    """
    sector = choice(SECTORS)
    images = PNGs + JPEGs
    image_1, image_2, image_3 = (choice(images) for _ in range(3))
    (
        title,
        summary,
        description,
        caption_1,
        caption_2,
        caption_3,
        testimonial,
        source_name,
        source_job,
        source_company,
    ) = (sentence() for _ in range(10))
    website = "http://{}.{}".format(rare_word(), rare_word())
    keywords = ", ".join(sentence().split())

    case_study = CaseStudy(
        alias=alias,
        title=title,
        summary=summary,
        description=description,
        sector=sector,
        website=website,
        keywords=keywords,
        image_1=image_1,
        image_2=image_2,
        image_3=image_3,
        caption_1=caption_1,
        caption_2=caption_2,
        caption_3=caption_3,
        testimonial=testimonial,
        source_name=source_name,
        source_job=source_job,
        source_company=source_company,
    )

    return case_study
Esempio n. 4
0
 def search(self):
     url = URLs.FAS_SEARCH.relative
     params = {"q": rare_word(), "industries": random_sector()}
     self.client.get(
         url,
         params=params,
         headers=LOAD_TESTS_USER_AGENT,
         name="/search/?q=[term]&industries=[sectors]",
         auth=basic_auth(),
     )
Esempio n. 5
0
 def search_by_term(self):
     url = URLs.ISD_SEARCH.relative
     params = {"q": rare_word()}
     self.client.get(
         url,
         params=params,
         headers=LOAD_TESTS_USER_AGENT,
         name="/search/?q={term}",
         auth=basic_auth(),
     )
Esempio n. 6
0
    def search(self):
        url = URLs.DOMESTIC_SEARCH.relative
        params = {"q": rare_word()}

        self.client.get(
            url,
            params=params,
            headers=LOAD_TESTS_USER_AGENT,
            name="search/?q=[...]",
            auth=basic_auth(),
        )
Esempio n. 7
0
 def companies_house_search_by_term(self):
     url = URLs.PROFILE_API_COMPANIES_HOUSE_SEARCH.relative
     params = {
         "term": random.choice([random_company_number(),
                                rare_word()])
     }
     self.client.get(
         url,
         params=params,
         headers=LOAD_TESTS_USER_AGENT,
         name=URLs.PROFILE_API_COMPANIES_HOUSE_SEARCH.template,
         auth=basic_auth(),
     )
Esempio n. 8
0
def random_message_data(
    *,
    alias: str = None,
    body: str = None,
    company_name: str = None,
    country: str = None,
    email_address: str = None,
    family_name: str = None,
    given_name: str = None,
    g_recaptcha_response: str = None,
    sector: str = None,
    subject: str = None,
    terms: str = None,
) -> Feedback:
    alias = alias or "test message"
    body = body or sentence(max_length=1000)
    company_name = company_name or f"{rare_word()} AUTOTESTS"
    country = country or rare_word()
    email_address = email_address or f"test+buyer_{rare_word()}@{TEST_EMAIL_DOMAIN}"
    family_name = family_name or sentence(min_words=2, max_words=2)
    given_name = given_name or sentence(min_words=2, max_words=2)
    sector = sector or random.choice(SECTORS)
    subject = subject or sentence(max_length=200)
    g_recaptcha_response = g_recaptcha_response or "test mode"
    terms = terms or "on"

    message = Message(
        alias=alias,
        body=body,
        company_name=company_name,
        country=country,
        email_address=email_address,
        family_name=family_name,
        given_name=given_name,
        g_recaptcha_response=g_recaptcha_response,
        sector=sector,
        subject=subject,
        terms=terms,
    )

    return message