Skip to content

Commit

Permalink
Migrate test_get_next_results to Travis suite
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Apr 18, 2018
1 parent 2550e65 commit e63ff9d
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -78,7 +78,7 @@ matrix:
- SITE_URL='https://treeherder.dev' TREEHERDER_DEBUG='False' ./manage.py check --deploy --fail-level WARNING
# Using Python 2's `-3` mode to surface DeprecationWarnings for Python 3 incompatibilities:
# https://docs.python.org/2/using/cmdline.html#cmdoption-3
- python -3 -m pytest tests/ --runslow --ignore=tests/selenium/ --ignore=tests/jenkins/
- python -3 -m pytest tests/ --runslow --ignore=tests/selenium/

# Job 5: Python Tests - Selenium integration
- env: python-tests-selenium
Expand Down
8 changes: 4 additions & 4 deletions setup.cfg
@@ -1,5 +1,5 @@
[pycodestyle]
exclude = .git,__pycache__,.vagrant,node_modules,tests/jenkins
exclude = .git,__pycache__,.vagrant,node_modules
# E121,E123,E126,E226,E24,E704,W503: Ignored in default pycodestyle config:
# https://github.com/PyCQA/pycodestyle/blob/2.2.0/pycodestyle.py#L72
# Our additions...
Expand All @@ -12,22 +12,22 @@ max-line-length = 140
# flake8 is a combination of pyflakes & pycodestyle.
# Unfortunately we have to mostly duplicate the above, since some tools use
# pycodestyle's config (eg autopep8) so we can't just define everything under [flake8].
exclude = .git,__pycache__,.vagrant,node_modules,tests/jenkins
exclude = .git,__pycache__,.vagrant,node_modules
# The ignore list for pycodestyle above, plus our own PyFlakes additions:
# F403: 'from module import *' used; unable to detect undefined names
# F405: name may be undefined, or defined from star imports: module
ignore = E121,E123,E126,E129,E226,E24,E704,W503,E501,F403,F405
max-line-length = 140

[isort]
skip = .git,__pycache__,.vagrant,node_modules,migrations,tests/jenkins
skip = .git,__pycache__,.vagrant,node_modules,migrations
multi_line_output = 1
force_grid_wrap = true
line_length = 140

[tool:pytest]
testpaths = tests
norecursedirs = __pycache__ jenkins ui
norecursedirs = __pycache__ ui
DJANGO_SETTINGS_MODULE=tests.settings
# Disable unused auto-loaded plugins.
addopts = --driver Firefox -p no:mozlog -p no:metadata -p no:html
Expand Down
68 changes: 0 additions & 68 deletions tests/jenkins/Jenkinsfile

This file was deleted.

Empty file removed tests/jenkins/pages/__init__.py
Empty file.
54 changes: 0 additions & 54 deletions tests/jenkins/pages/treeherder.py

This file was deleted.

7 changes: 0 additions & 7 deletions tests/jenkins/requirements.txt

This file was deleted.

Empty file removed tests/jenkins/tests/__init__.py
Empty file.
22 changes: 0 additions & 22 deletions tests/jenkins/tests/conftest.py

This file was deleted.

12 changes: 0 additions & 12 deletions tests/jenkins/tests/test_get_next_results.py

This file was deleted.

22 changes: 0 additions & 22 deletions tests/jenkins/tox.ini

This file was deleted.

18 changes: 18 additions & 0 deletions tests/selenium/pages/treeherder.py
Expand Up @@ -23,6 +23,9 @@ class Treeherder(Base):
_filter_superseded_locator = (By.CSS_SELECTOR, '.btn-nav-filter[title=superseded]')
_filter_usercancel_locator = (By.CSS_SELECTOR, '.btn-nav-filter[title=usercancel]')
_filters_menu_locator = (By.ID, 'filterLabel')
_get_next_10_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(1)')
_get_next_20_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(2)')
_get_next_50_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(3)')
_quick_filter_locator = (By.ID, 'quick-filter')
_repo_locator = (By.CSS_SELECTOR, '#repo-dropdown a[href*="repo={}"]')
_repo_menu_locator = (By.ID, 'repoLabel')
Expand Down Expand Up @@ -76,6 +79,21 @@ def filters_menu(self):
def filter_unclassified_jobs(self):
self.find_element(*self._unclassified_filter_locator).click()

def _get_next(self, count):
before = len(self.pushes)
locator = getattr(self, '_get_next_{}_locator'.format(count))
self.find_element(*locator).click()
self.wait.until(lambda s: len(self.pushes) == before + count)

def get_next_10(self):
self._get_next(10)

def get_next_20(self):
self._get_next(20)

def get_next_50(self):
self._get_next(50)

@property
def info_panel(self):
return self.InfoPanel(self)
Expand Down
30 changes: 30 additions & 0 deletions tests/selenium/test_get_next_results.py
@@ -0,0 +1,30 @@
import time

import pytest

from pages.treeherder import Treeherder


@pytest.fixture
def sample_push():
sample_push = []
for i in range(61):
sample_push.append({
'revision': 'revision{}'.format(i),
'push_timestamp': int(time.time() + (i * 3600)),
'author': 'Test author <test@example.com>',
'revisions': [{
'comment': 'Test commit',
'author': 'Test author <test@example.com>',
'revision': 'revision{}'.format(i)
}]
})
return sample_push


@pytest.mark.parametrize('count', ((10), (20), (50)))
def test_get_next_results(base_url, selenium, count, push_stored):
page = Treeherder(selenium, base_url).open()
page.wait.until(lambda _: 10 == len(page.pushes))
getattr(page, 'get_next_{}'.format(count))()
assert len(page.pushes) == 10 + count
2 changes: 1 addition & 1 deletion treeherder/model/fixtures/repository.json
Expand Up @@ -1215,7 +1215,7 @@
"name": "treeherder",
"url": "https://github.com/mozilla/treeherder",
"branch": "master",
"active_status": "active",
"active_status": "onhold",
"codebase": "treeherder",
"repository_group": 5,
"description": "A system for managing CI data for Mozilla projects"
Expand Down

0 comments on commit e63ff9d

Please sign in to comment.