Пример #1
0
def fas_should_see_all_case_studies(context: Context, supplier_alias: str):
    """Check if Supplier can see all case studies on FAS profile page."""
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    response = fas.profile.go_to(actor.session, company.number)
    context.response = response
    fas.profile.should_be_here(response)
    case_studies = get_company(context, actor.company_alias).case_studies
    fas.profile.should_see_case_studies(case_studies, response)
    logging.debug(
        "%s can see all %d Case Studies on FAS Company's " "Directory Profile Page",
        supplier_alias,
        len(case_studies),
    )
Пример #2
0
def fas_should_see_company_once_in_search_results(
    context: Context, actor_alias: str, company_alias: str
):
    company = get_company(context, company_alias)
    results = context.results
    founds = [
        (page, result["found"]) for page, result in results.items() if result["found"]
    ]
    with assertion_msg(
        "Expected to see company '%s' only once on first %d search result "
        "pages but found it %d times. On pages: %s",
        company.title,
        len(results),
        len(founds),
        founds,
    ):
        assert len(founds) == 1
    logging.debug(
        "As expected %s found company '%s' (%s) only once on first %d search "
        "result pages",
        actor_alias,
        company.title,
        company_alias,
        len(results) + 1,
    )
Пример #3
0
def fas_should_see_different_png_logo_thumbnail(context: Context, actor_alias: str):
    """Will check if Company's Logo visible on FAS profile page is the same as
    the one uploaded on FAB.
    """
    actor = get_actor(context, actor_alias)
    session = actor.session
    company = get_company(context, actor.company_alias)
    fas_logo_url = company.logo_url

    # Step 1 - Go to the FAS profile page & extract URL of visible logo image
    response = fas.profile.go_to(session, company.number)
    context.response = response
    fas.profile.should_be_here(response)
    visible_logo_url = extract_logo_url(response)
    placeholder = FAS_LOGO_PLACEHOLDER_IMAGE

    with assertion_msg(
        "Expected company logo but got image placeholder", visible_logo_url
    ):
        assert visible_logo_url != placeholder
    with assertion_msg(
        "Expected to see other logo thumbnail than the previous one '%s'.",
        visible_logo_url,
    ):
        assert visible_logo_url != fas_logo_url
    with assertion_msg("Expected PNG logo thumbnail, but got: %s", visible_logo_url):
        assert visible_logo_url.lower().endswith(".png")
Пример #4
0
def fas_should_be_told_that_message_has_been_sent(
    context: Context, buyer_alias: str, company_alias: str
):
    response = context.response
    company = get_company(context, company_alias)
    fas.contact.should_see_that_message_has_been_sent(company, response)
    logging.debug(
        "%s was told that the message to '%s' (%s) has been sent",
        buyer_alias,
        company.title,
        company_alias,
    )
Пример #5
0
def profile_should_get_request_for_becoming_owner(
    context: Context, new_owner_alias: str, company_alias: str
):
    actor = get_actor(context, new_owner_alias)
    company = get_company(context, company_alias)
    subject = PROFILE_INVITATION_MSG_SUBJECT.format(company_title=company.title.upper())
    link = get_verification_link(actor.email, subject=subject)
    update_actor(
        context,
        new_owner_alias,
        ownership_request_link=link,
        company_alias=company_alias,
    )
Пример #6
0
def profile_should_see_company_details(
    context: Context, supplier_alias: str, page_name: str
):
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    page = get_page_object(page_name)
    has_action(page, "go_to")
    has_action(page, "should_see_details")
    if "company_number" in inspect.getfullargspec(page.go_to).args:
        context.response = page.go_to(actor.session, company_number=company.number)
    else:
        context.response = page.go_to(actor.session)
    page.should_see_details(company, context.response, context.table)
    logging.debug(f"{supplier_alias} can see all expected details on {page_name}")
Пример #7
0
def fas_check_profiles(context: Context, supplier_alias: str):
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    # Step 1 - go to company's profile page on FAS
    response = fas.profile.go_to(actor.session, company.number)
    context.response = response
    fas.profile.should_be_here(response)
    # Step 2 - check if links to online profile are visible
    fas.profile.should_see_online_profiles(company, response)
    logging.debug(
        "%s can see all expected links to Online Profiles on "
        "FAS Company's Directory Profile Page",
        supplier_alias,
    )
Пример #8
0
def sso_should_get_request_for_collaboration_email(
    context: Context, actor_aliases: str, company_alias: str
):
    actor_aliases = [alias.strip() for alias in actor_aliases.split(",")]
    for actor_alias in actor_aliases:
        actor = get_actor(context, actor_alias)
        company = get_company(context, company_alias)
        subject = PROFILE_INVITATION_MSG_SUBJECT.format(
            company_title=company.title.upper()
        )
        link = get_verification_link(actor.email, subject=subject)
        update_actor(
            context,
            actor_alias,
            invitation_for_collaboration_link=link,
            company_alias=company_alias,
        )
Пример #9
0
def fas_supplier_cannot_be_found_using_case_study_details(
    context: Context, buyer_alias: str, company_alias: str, case_alias: str
):
    actor = get_actor(context, buyer_alias)
    session = actor.session
    company = get_company(context, company_alias)
    case_study = company.case_studies[case_alias]
    keys = SEARCHABLE_CASE_STUDY_DETAILS
    search_terms = {}
    for key in keys:
        if key == "keywords":
            for index, keyword in enumerate(case_study.keywords.split(", ")):
                search_terms[f"keyword #{index}"] = keyword
        else:
            search_terms[key] = getattr(case_study, key)
    logging.debug(
        "Now %s will try to find '%s' using following search terms: %s",
        buyer_alias,
        company.title,
        search_terms,
    )
    for term_name in search_terms:
        term = search_terms[term_name]
        logging.debug(
            "Searching for '%s' using %s: %s", company.title, term_name, search_terms
        )
        response = fas.search.go_to(session, term=term)
        context.response = response
        fas.search.should_be_here(response)
        found = fas.search.should_not_see_company(response, company.title)
        with assertion_msg(
            "Buyer found Supplier '%s' on FAS using %s: %s",
            company.title,
            term_name,
            term,
        ):
            assert found
        logging.debug(
            "Buyer was not able to find unverified Supplier '%s' on FAS using "
            "%s: %s",
            company.title,
            term_name,
            term,
        )
Пример #10
0
def profile_should_see_logo_picture(context: Context, supplier_alias: str):
    """Will check if Company's Logo visible on FAB profile page is the same as
    the uploaded one.
    """
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    logo_url = company.logo_url
    logo_hash = company.logo_hash
    logo_picture = company.logo_picture

    logging.debug(
        "Fetching logo image visible on the %s's FAB profile page", company.title
    )
    check_hash_of_remote_file(logo_hash, logo_url)
    logging.debug(
        "The Logo visible on the %s's FAB profile page is the same " "as uploaded %s",
        company.title,
        logo_picture,
    )
Пример #11
0
def profile_should_be_told_about_invalid_links(context: Context, supplier_alias: str):
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)

    facebook = True if company.facebook else False
    linkedin = True if company.linkedin else False
    twitter = True if company.twitter else False

    profile.edit_online_profiles.should_see_errors(
        context.response, facebook=facebook, linkedin=linkedin, twitter=twitter
    )
    logging.debug(
        "%s was not able to set Company's Online Profile links using invalid "
        "URLs to: %s %s %s",
        supplier_alias,
        "Facebook" if facebook else "",
        "LinkedIn" if linkedin else "",
        "Twitter" if twitter else "",
    )
Пример #12
0
def fas_should_see_png_logo_thumbnail(context: Context, supplier_alias: str):
    """Will check if Company's PNG thumbnail logo visible on FAS profile."""
    actor = get_actor(context, supplier_alias)
    session = actor.session
    company = get_company(context, actor.company_alias)

    # Step 1 - Go to the FAS profile page & extract URL of visible logo image
    response = fas.profile.go_to(session, company.number)
    context.response = response
    fas.profile.should_be_here(response)
    visible_logo_url = extract_logo_url(response)
    placeholder = FAS_LOGO_PLACEHOLDER_IMAGE

    with assertion_msg(
        "Expected company logo but got image placeholder '%s'", visible_logo_url
    ):
        assert visible_logo_url != placeholder
    with assertion_msg("Expected PNG logo thumbnail, but got: %s", visible_logo_url):
        assert visible_logo_url.lower().endswith(".png")
    set_company_logo_detail(context, actor.company_alias, url=visible_logo_url)
    logging.debug("Set Company's logo URL to: %s", visible_logo_url)
Пример #13
0
def fas_should_find_with_company_details(
    context: Context, buyer_alias: str, company_alias: str
):
    """Check if Buyer was able to find Supplier using all selected search terms

    NOTE:
    This step requires the search_results dict to be stored in context
    """
    assert hasattr(context, "search_results")
    company = get_company(context, company_alias)
    for result in context.search_results:
        # get response for specific search request. This helps to debug
        logging.debug(f"Search results: {context.search_results}")
        context.response = context.search_responses[result]
        with assertion_msg(
            "%s wasn't able to find '%s' (alias: %s) using its '%s'",
            buyer_alias,
            company.title,
            company_alias,
            result,
        ):
            assert context.search_results[result]
Пример #14
0
def fas_find_supplier_using_case_study_details(
    context: Context,
    buyer_alias: str,
    company_alias: str,
    case_alias: str,
    *,
    properties: Table = None,
    max_pages: int = 5,
):
    """Find Supplier on FAS using parts of the Case Study added by Supplier.

    :param context: behave `context` object
    :param buyer_alias: alias of the Actor used in the scope of the scenario
    :param company_alias: alias of the sought Company
    :param case_alias: alias of the Case Study used in the search
    :param properties: (optional) table containing the names of Case Study
                       parts that will be used search. If not provided, then
                       all parts will be used except 'alias'.
    :param max_pages: (optional) maximum number of search result pages to go
                      through
    """
    actor = get_actor(context, buyer_alias)
    session = actor.session
    company = get_company(context, company_alias)
    case_study = company.case_studies[case_alias]
    keys = SEARCHABLE_CASE_STUDY_DETAILS
    if properties:
        keys = [row["search using case study's"] for row in properties]
    search_terms = {}
    for key in keys:
        # if key == "keywords":
        #     for index, keyword in enumerate(case_study.keywords.split(", ")):
        #         search_terms[f"keyword #{index}"] = keyword
        # else:
        search_terms[key] = getattr(case_study, key.replace(" ", "_"))
    logging.debug(
        "Now %s will try to find '%s' using following search terms: %s",
        buyer_alias,
        company.title,
        search_terms,
    )

    search_results = defaultdict()
    for term_type in search_terms:
        term = search_terms[term_type]
        logging.debug(f"Looking for '{company.title}' using '{term_type}': '{term}'")
        profile_link, context.response = can_find_supplier_by_term(
            session, company.title, term, term_type, max_pages=max_pages
        )
        found = profile_link != ""
        search_results[term_type] = {"term": term, "found": found}

    logging.debug(f"Search results: {search_results}")
    not_found_by = {
        term_type: search_results
        for term_type, search_results in search_results.items()
        if not search_results["found"]
    }
    not_found_by_str = "; ".join(
        [f"{k} → {v['term']}" for k, v in not_found_by.items()]
    )
    with assertion_msg(
        f"Couldn't find '{company.title}' on FAS using following case study "
        f"details: {not_found_by_str}"
    ):
        assert not not_found_by
    logging.debug(
        f"{buyer_alias} was able to find company '{company.title} using all "
        f"case study details: {search_terms}"
    )
Пример #15
0
def profile_should_see_online_profiles(context: Context, supplier_alias: str):
    """Check if Supplier can see all online Profiles on FAB Profile page."""
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    response = context.response
    profile.edit_company_profile.should_see_online_profiles(company, response)
Пример #16
0
def fas_should_be_on_profile_page(context, supplier_alias, company_alias):
    actor = get_actor(context, supplier_alias)
    company = get_company(context, actor.company_alias)
    fas.profile.should_be_here(context.response, number=company.number)
    logging.debug("%s is on the %s company's FAS page", supplier_alias, company_alias)
Пример #17
0
def profile_should_see_all_case_studies(context: Context, supplier_alias: str):
    """Check if Supplier can see all case studies on FAB profile page."""
    actor = get_actor(context, supplier_alias)
    case_studies = get_company(context, actor.company_alias).case_studies
    profile.edit_company_profile.should_see_case_studies(case_studies, context.response)