Esempio n. 1
0
def test_search_users_matches_pattern(sdk: mtds.LookerSDK,
                                      users: List[Dict[str, str]],
                                      email_domain: str):
    """search_users should return a list of all matches.
    """
    user = users[0]

    # Search by full email
    search_email = f'{user["first_name"]}.{user["last_name"]}{email_domain}'
    search_results = sdk.search_users_names(pattern=search_email)
    assert len(search_results) == 1
    assert search_results[0].first_name == user["first_name"]
    assert search_results[0].last_name == user["last_name"]
    assert search_results[0].email == search_email

    # Search by first name
    search_results = sdk.search_users_names(pattern=user["first_name"])
    assert len(search_results) > 0
    assert search_results[0].first_name == user["first_name"]

    # First name with spaces
    u = sdk.create_user(
        ml.WriteUser(first_name="John Allen", last_name="Smith"))
    if u.id:
        search_results = sdk.search_users_names(pattern="John Allen")
        assert len(search_results) == 1
        assert search_results[0].first_name == "John Allen"
        assert search_results[0].last_name == "Smith"

        # Delete user
        resp = sdk.delete_user(u.id)
        assert resp == ""
Esempio n. 2
0
def test_delim_sequence(sdk: mtds.LookerSDK, email_domain: str,
                        users: List[Dict[str, str]]):
    search_results = sdk.search_users_names(pattern=f"%{email_domain}")
    assert len(search_results) == len(users)
    delim_ids = ml.DelimSequence([cast(int, u.id) for u in search_results])
    all_users = sdk.all_users(ids=delim_ids)
    assert len(all_users) == len(users)
Esempio n. 3
0
def test_it_matches_email_domain_and_returns_sorted(sdk: mtds.LookerSDK,
                                                    email_domain: str,
                                                    users: List[Dict[str,
                                                                     str]]):
    """search_users_names() should search users matching a given pattern and return
    sorted results if sort fields are specified.
    """
    search_results = sdk.search_users_names(pattern=f"%{email_domain}",
                                            sorts="last_name, first_name")
    assert len(search_results) == len(users)
    sorted_test_data: List[Dict[str, str]] = sorted(users,
                                                    key=itemgetter(
                                                        "last_name",
                                                        "first_name"))
    for actual, expected in zip(search_results, sorted_test_data):
        assert actual.first_name == expected["first_name"]
        assert actual.last_name == expected["last_name"]