redash-ui-tests/tests/test_queries.py

130 строки
3.5 KiB
Python
Исходник Обычный вид История

2018-06-28 14:47:23 +03:00
# -*- coding: utf-8 -*-
"""UI tests for the queries page."""
2018-06-26 00:47:21 +03:00
import pytest
2018-06-28 14:47:23 +03:00
from models.user import User
2018-08-03 22:28:25 +03:00
from pages.home import HomePage
2018-06-28 14:47:23 +03:00
from pages.login import LoginPage
2018-06-26 00:47:21 +03:00
@pytest.mark.parametrize(
"search_term, description",
[
("Default Query", "Test query for redash UI tests."),
("Ashleys Query", "Query created by Ashley."),
],
)
2018-08-03 22:28:25 +03:00
def test_query_by_username(
2018-06-28 14:47:23 +03:00
create_queries,
login_page: LoginPage,
search_term: str,
description: str,
user: User,
) -> None:
2018-08-07 17:36:55 +03:00
"""Search for query by username."""
2018-06-26 00:47:21 +03:00
page = login_page.login(email=user.email, password=user.password)
search = page.search(search_term)
query = search.queries[0].click()
assert query.description == description
2018-08-03 22:28:25 +03:00
@pytest.mark.parametrize(
"search_term, description",
[
("Default Query", "Test query for redash UI tests."),
("Ashleys Query", "Query created by Ashley."),
],
)
def test_query_by_description(
create_queries,
login_page: LoginPage,
search_term: str,
description: str,
user: User,
) -> None:
2018-08-07 17:36:55 +03:00
"""Search for query using description."""
2018-08-03 22:28:25 +03:00
page = login_page.login(email=user.email, password=user.password)
search = page.search(description)
query = search.queries[0].click()
assert query.description == description
def test_query_by_weird_capitalization(
create_queries,
login_page: LoginPage,
org,
user: User,
variables,
) -> None:
2018-08-07 17:36:55 +03:00
"""Search for query with weird capitalization."""
2018-08-03 22:28:25 +03:00
term = variables[org]["queries"]["capitalization"]
page = login_page.login(email=user.email, password=user.password)
search = page.search(term["name"])
query = search.queries[0].click()
assert query.description == term["description"]
def test_query_by_number(
create_queries,
login_page: LoginPage,
org,
user: User,
variables,
) -> None:
2018-08-07 17:36:55 +03:00
"""Search for query with numbers in the name."""
2018-08-03 22:28:25 +03:00
term = variables[org]["queries"]["numbers"]
page = login_page.login(email=user.email, password=user.password)
search = page.search(term['name'])
query = search.queries[0].click()
assert query.description == term["description"]
def test_query_by_special_char(
create_queries,
login_page: LoginPage,
org,
user: User,
variables,
) -> None:
2018-08-07 17:36:55 +03:00
"""Search for query wioth special characters in name."""
2018-08-03 22:28:25 +03:00
term = variables[org]["queries"]["special-char"]
page = login_page.login(email=user.email, password=user.password)
search = page.search(term['name'])
query = search.queries[0].click()
assert query.description == term["description"]
def test_search_for_unpublished_query(
create_queries,
login_page: LoginPage,
server_url,
selenium,
user: User,
) -> None:
"""Publish a query and then search for the unpublished one."""
page = login_page.login(email=user.email, password=user.password)
search = page.search("Publish Query")
query = search.queries[0].click()
query.publish()
page = HomePage(selenium, server_url).open()
search = page.search("Ashleys Query")
query = search.queries[0].click()
assert query.description == "Query created by Ashley."
2018-08-07 17:36:55 +03:00
def test_search_for_query_by_id(
create_queries,
login_page: LoginPage,
server_url,
selenium,
user: User,
) -> None:
"""Search for a query by its id."""
page = login_page.login(email=user.email, password=user.password)
search = page.search("1")
query = search.queries[0].click()
assert query.description == "Query created by Ashley."