зеркало из https://github.com/mozilla/treeherder.git
Use common fixtures in Selenium tests
This commit is contained in:
Родитель
e6017f74c9
Коммит
d49c1846fa
|
@ -16,7 +16,8 @@ from treeherder.client.thclient import TreeherderClient
|
|||
from treeherder.config.wsgi import application
|
||||
from treeherder.etl.jobs import store_job_data
|
||||
from treeherder.etl.push import store_push_data
|
||||
from treeherder.model.models import (JobNote,
|
||||
from treeherder.model.models import (Commit,
|
||||
JobNote,
|
||||
Push,
|
||||
TextLogErrorMetadata)
|
||||
|
||||
|
@ -125,6 +126,24 @@ def test_repository_2(test_repository):
|
|||
codebase=test_repository.codebase)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_push(test_repository):
|
||||
return Push.objects.create(
|
||||
repository=test_repository,
|
||||
revision="4c45a777949168d16c03a4cba167678b7ab65f76",
|
||||
author="foo@bar.com",
|
||||
time=datetime.datetime.now())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_commit(test_push):
|
||||
return Commit.objects.create(
|
||||
push=test_push,
|
||||
revision=test_push.revision,
|
||||
author=test_push.author,
|
||||
comments="Bug 12345 - This is a message")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_job(test_repository, failure_classifications, eleven_job_blobs):
|
||||
from treeherder.model.models import Job
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
from django.core.management import call_command
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
@ -10,8 +9,3 @@ def base_url(live_server):
|
|||
@pytest.fixture(scope='session')
|
||||
def sensitive_url(request, base_url):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def initial_data(transactional_db):
|
||||
call_command('load_initial_data')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.conf import settings
|
||||
from pypom import Region
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as expected
|
||||
|
@ -7,13 +8,16 @@ from .base import Base
|
|||
|
||||
class Treeherder(Base):
|
||||
|
||||
URL_TEMPLATE = '/#/jobs?repo={}'.format(settings.TREEHERDER_TEST_REPOSITORY_NAME)
|
||||
|
||||
_active_watched_repo_locator = (By.CSS_SELECTOR, '#watched-repo-navbar button.active')
|
||||
_mozilla_central_repo_locator = (By.CSS_SELECTOR, '#repo-dropdown a[href*="repo=mozilla-central"]')
|
||||
_repos_menu_locator = (By.ID, 'repoLabel')
|
||||
_repo_locator = (By.CSS_SELECTOR, '#repo-dropdown a[href*="repo={}"]')
|
||||
_repo_menu_locator = (By.ID, 'repoLabel')
|
||||
_result_sets_locator = (By.CSS_SELECTOR, '.result-set:not(.row)')
|
||||
_watched_repos_locator = (By.CSS_SELECTOR, '#watched-repo-navbar th-watched-repo')
|
||||
|
||||
def wait_for_page_to_load(self):
|
||||
self.wait.until(lambda _: self.is_element_displayed(*self._active_watched_repo_locator))
|
||||
self.wait.until(lambda _: self.find_elements(*self._watched_repos_locator))
|
||||
return self
|
||||
|
||||
@property
|
||||
|
@ -24,11 +28,12 @@ class Treeherder(Base):
|
|||
def result_sets(self):
|
||||
return [self.ResultSet(self, el) for el in self.find_elements(*self._result_sets_locator)]
|
||||
|
||||
def select_mozilla_central_repo(self):
|
||||
self.find_element(*self._repos_menu_locator).click()
|
||||
def select_repository(self, name):
|
||||
self.find_element(*self._repo_menu_locator).click()
|
||||
# FIXME workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1411264
|
||||
el = self.find_element(By.CSS_SELECTOR, 'body')
|
||||
self.find_element(*self._mozilla_central_repo_locator).click()
|
||||
locator = (self._repo_locator[0], self._repo_locator[1].format(name))
|
||||
self.find_element(*locator).click()
|
||||
self.wait.until(expected.staleness_of(el))
|
||||
self.wait_for_page_to_load()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from pages.treeherder import Treeherder
|
||||
|
||||
|
||||
def test_switch_app(base_url, selenium):
|
||||
def test_switch_app(base_url, selenium, test_repository):
|
||||
"""Switch between Treeherder and Perfherder using header dropdown"""
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
assert page.header.active_app == 'Treeherder'
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from pages.treeherder import Treeherder
|
||||
|
||||
|
||||
def test_switch_repo(base_url, selenium):
|
||||
def test_switch_repo(base_url, selenium, test_repository, test_repository_2):
|
||||
"""Switch to new active watched repo"""
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
assert 'mozilla-inbound' == page.active_watched_repo
|
||||
page.select_mozilla_central_repo()
|
||||
assert 'mozilla-central' == page.active_watched_repo
|
||||
assert test_repository.name == page.active_watched_repo
|
||||
page.select_repository(test_repository_2.name)
|
||||
assert test_repository_2.name == page.active_watched_repo
|
||||
|
|
|
@ -1,43 +1,13 @@
|
|||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from pages.treeherder import Treeherder
|
||||
from treeherder.model.models import (Commit,
|
||||
Push,
|
||||
Repository)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def repository():
|
||||
return Repository.objects.get(name='mozilla-inbound')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def push(repository):
|
||||
return Push.objects.create(
|
||||
repository=repository,
|
||||
revision="4c45a777949168d16c03a4cba167678b7ab65f76",
|
||||
author="foo@bar.com",
|
||||
time=datetime.datetime.now())
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def commit(push):
|
||||
return Commit.objects.create(
|
||||
push=push,
|
||||
revision=push.revision,
|
||||
author=push.author,
|
||||
comments="Bug 12345 - This is a message")
|
||||
|
||||
|
||||
def test_open_single_result(base_url, selenium, commit):
|
||||
def test_open_single_result(base_url, selenium, test_commit):
|
||||
page = Treeherder(selenium, base_url).open()
|
||||
page.wait.until(lambda _: 1 == len(page.result_sets))
|
||||
page.result_sets[0].view()
|
||||
assert 1 == len(page.result_sets)
|
||||
assert commit.author == page.result_sets[0].author
|
||||
assert commit.push.time.strftime('%a %b %-d, %H:%M:%S') == page.result_sets[0].datestamp
|
||||
assert test_commit.author == page.result_sets[0].author
|
||||
assert test_commit.push.time.strftime('%a %b %-d, %H:%M:%S') == page.result_sets[0].datestamp
|
||||
assert 1 == len(page.result_sets[0].commits)
|
||||
assert commit.revision[:12] == page.result_sets[0].commits[0].revision
|
||||
assert commit.comments == page.result_sets[0].commits[0].comment
|
||||
assert test_commit.revision[:12] == page.result_sets[0].commits[0].revision
|
||||
assert test_commit.comments == page.result_sets[0].commits[0].comment
|
||||
|
|
Загрузка…
Ссылка в новой задаче