Skip to content

Commit

Permalink
A basic test; Travis/Coveralls setup; RTD setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Falešník committed Apr 7, 2017
1 parent 1fe069c commit e9ab2ee
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 3 deletions.
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject


28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: python
python:
- '2.7'
- '3.3'
- '3.4'
- '3.5'
install: pip install tox-travis
script: tox
after_success:
- coveralls
deploy:
provider: pypi
user: mfalesni
password:
secure: eklp+CztKhp2FC5+JU+pt6xsPeulsSU087fFgHTpVbuuN0cCu7ZMSN13A+l74L17Uxa8n7rH5icJFQNvjWToioDzyWHvOvkyy6KKSHYHbXqLQdk8DPBW4mUq9SRcfmePsmxTb91kgr14KdaLnJpZZICwMcutRBKF4mm1XBMVPPNucDDyOUtoQAcLE92wGZD14VJPxFO09dDHj7qy36iOS2ZvLGFIi2TmE6TuFlG3gvXfgTXNAkFEHgu3xrf1y1Z71SX2dsa5gJ4LKq+QY+SRhlBFOwnktSjVudZEVei4JjxaJWCKBG66o4vg9cDGh6o6nJZkTaJoImtt0Vv2AzXqw3RHht5J4yudvtn81jmP767cdaS7YIdC3AZ8MiEiDbbAo0OSu0paF8mgIC6XAAXHJ08aDIdTOrQlgsmQLjN+ft7Q5hozEzpiHzPDMYzYixVoPjeFDY943g0eEN7XO7dcyQQAfrEb7fGKTkO8EaOcGBmxFJvba1gd315V1a2iG46QZG6O5qdwZrPqYhggi39zJzjVynBRrl9g4kVu5WWnucWdIv3LUTfyFnhNrFAT6XDNMOSTWCdPuP3EDj/aiOXu6FRp4+PW0vpKB0DrmSLRKlWpNe43jd+YqnJJRkm4jyIh+SX+Nj39fKagbdHWFbxUtomrsawfC2EpzMhqA6CPEbA=
on:
tags: true
distributions: sdist bdist_wheel
repo: RedHatQE/widgetastic.patternfly
before_install:
- "export PHANTOMJS_VERSION=2.1.1"
- "phantomjs --version"
- "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"
- "phantomjs --version"
- "if [ $(phantomjs --version) != '$PHANTOMJS_VERSION' ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
- "if [ $(phantomjs --version) != '$PHANTOMJS_VERSION' ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi"
- "if [ $(phantomjs --version) != '$PHANTOMJS_VERSION' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
- "phantomjs --version"
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
widgetastic.patternfly
======================

.. image:: https://travis-ci.org/RedHatQE/widgetastic.patternfly.svg?branch=master
:target: https://travis-ci.org/RedHatQE/widgetastic.patternfly

.. image:: https://coveralls.io/repos/github/RedHatQE/widgetastic.patternfly/badge.svg?branch=master
:target: https://coveralls.io/github/RedHatQE/widgetastic.patternfly?branch=master

.. image:: https://readthedocs.org/projects/widgetasticpatternfly/badge/?version=latest
:target: http://widgetasticpatternfly.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://www.quantifiedcode.com/api/v1/project/a13ed499c97547598b1507ae7f5c5f47/badge.svg
:target: https://www.quantifiedcode.com/app/project/a13ed499c97547598b1507ae7f5c5f47
:alt: Code issues

Patternfly_ widget library for Widgetastic_.

.. _Patternfly: http://www.patternfly.org
Expand Down
62 changes: 62 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
import os
import pkg_resources
import six
import sys

from datetime import datetime

__distribution = pkg_resources.get_distribution('widgetastic.patternfly')

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
]

intersphinx_mapping = {
'python': ('http://docs.python.org/2.7', None),
'pytest': ('http://pytest.org/latest/', None),
'selenium': ('http://selenium-python.readthedocs.org/', None),
'widgetastic.core': ('http://widgetasticcore.readthedocs.io/en/latest/', None),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'

# General information about the project.
project = __distribution.project_name
copyright = u'2016-{}, Milan Falešník (Apache license 2)'.format(datetime.now().year)
author = u'Milan Falešník'


# The full version, including alpha/beta/rc tags.
release = __distribution.version
version = '.'.join(release.split('.')[:2])

exclude_patterns = []

pygments_style = 'sphinx'
todo_include_todos = False


html_theme = 'haiku'
html_static_path = ['_static']

htmlhelp_basename = 'deprecatedoc'


def run_apidoc(_):
from sphinx.apidoc import main as apidoc_main
modules = ['src/widgetastic_patternfly']
for module in modules:
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(cur_dir, module, 'doc')
apidoc_main(['-e', '-f', '-o', output_path, module, '--force'])


def setup(app):
app.connect('builder-inited', run_apidoc)
17 changes: 17 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Welcome to widgetastic.patternfly's documentation!
==================================================

Contents:

.. toctree::
:maxdepth: 2

modules

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
6 changes: 3 additions & 3 deletions src/widgetastic_patternfly/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
"""This package contains classes that represent widgets in Patternfly for Widgetastic"""
from __future__ import unicode_literals

import re
Expand All @@ -18,8 +19,7 @@

class CandidateNotFound(Exception):
"""
Raised if there is no candidate found whilst trying to traverse a tree in
:py:meth:`cfme.web_ui.Tree.click_path`.
Raised if there is no candidate found whilst trying to traverse a tree.
"""
def __init__(self, d):
self.d = d
Expand Down Expand Up @@ -1003,7 +1003,7 @@ def expand_path(self, *path, **kwargs):
The leaf WebElement.
Raises:
:py:class:`exceptions.CandidateNotFound` when the node is not found in the tree.
:py:class:`CandidateNotFound` when the node is not found in the tree.
"""
self.browser.plugin.ensure_page_safe()
self.logger.info('Expanding path %s on tree %s', self.pretty_path(path), self.tree_id)
Expand Down
Empty file added testing/__init__.py
Empty file.
49 changes: 49 additions & 0 deletions testing/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import allure
import pytest

import codecs
import os
import sys

from selenium import webdriver

from widgetastic.browser import Browser

selenium_browser = None


class CustomBrowser(Browser):
@property
def product_version(self):
return '1.0.0'


@pytest.fixture(scope='session')
def selenium(request):
driver = webdriver.PhantomJS()
request.addfinalizer(driver.quit)
driver.maximize_window()
global selenium_browser
selenium_browser = driver
return driver


@pytest.fixture(scope='function')
def browser(selenium, httpserver, request):
this_module = sys.modules[__name__]
path = os.path.dirname(this_module.__file__)
testfilename = path + '/testing_page.html'
httpserver.serve_content(
codecs.open(testfilename, mode='r', encoding='utf-8').read(),
headers=[('Content-Type', 'text/html')])
selenium.get(httpserver.url)
return CustomBrowser(selenium)


def pytest_exception_interact(node, call, report):
if selenium_browser is not None:
allure.attach(
'Error screenshot', selenium_browser.get_screenshot_as_png(), allure.attach_type.PNG)
allure.attach('Error traceback', str(report.longrepr), allure.attach_type.TEXT)
13 changes: 13 additions & 0 deletions testing/test_buttons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from widgetastic.widget import View
from widgetastic_patternfly import Button


def test_button_click(browser):
class TestView(View):
button1 = Button('Default Normal')
button2 = Button(title='Destructive title')

view = TestView(browser)
assert view.button1.is_displayed
assert view.button2.is_displayed
38 changes: 38 additions & 0 deletions testing/testing_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--[if IE 8]><html class="ie8"><![endif]-->
<!--[if IE 9]><html class="ie9"><![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en" class="layout-pf layout-pf-fixed">
<!--<![endif]-->

<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/patternfly/3.23.1/css/patternfly.min.css" integrity="sha256-nNGxuG8p95S3RD1u5ABAy7lSfcf3gCQ9wNI5Q51lNB4=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/patternfly/3.23.1/css/patternfly-additions.css" integrity="sha256-JqQqupyMtGoBG/dyh3e8DjpScJ6G1iSCbqQTpPkKtjQ=" crossorigin="anonymous" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" integrity="sha256-3Jy/GbSLrg0o9y5Z5n1uw0qxZECH7C6OQpVBgNFYa0g=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/patternfly/3.23.1/js/patternfly.min.js" integrity="sha256-XI7ZZ/YpLWmMS6Kg6lkpgWT9sj1KC1DAq8Aw358n0zU=" crossorigin="anonymous"></script>
<title>Patternfly testing page</title>
</head>
<body>
<div class="container">
<p>
<button class="btn btn-default" type="button">Default Normal</button>
<button class="btn btn-primary" type="button">Primary Normal</button>
<button class="btn btn-danger" type="button" title="Destructive title">Destructive</button>
</p>
<p>
<button class="btn btn-default btn-lg " type="button">Secondary Large</button>
<button class="btn btn-primary btn-lg " type="button">Primary Large</button>
<button class="btn btn-danger btn-lg" type="button">Destructive Large</button>
</p>
<p>
<button class="btn btn-default btn-xs" type="button">Secondary Extra Small</button>
<button class="btn btn-primary btn-xs" type="button">Primary Extra Small</button>
<button class="btn btn-danger btn-xs" type="button">Destructive Extra Small</button>
</p>
</div>
</body>
</html>
36 changes: 36 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[tox]
envlist = py{27,33,34,35},codechecks

[testenv]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
deps=
pytest<=2.9.0,>=2.7.3
pytest-allure-adaptor
pytest-localserver
pytest-cov
coveralls
commands =
- py.test {posargs: -v --cov widgetastic_patternfly --cov-report term-missing --alluredir allure/}
- coveralls

[testenv:codechecks]
skip_install = true
deps= flake8
commands = flake8 {posargs:src testing}

[flake8]
max_line_length = 100

[testenv:docs]
deps = sphinx
commands =
sphinx-build \
-b html \
-d build/sphinx-doctrees \
docs build/htmldocs

[tox:travis]
2.7 = py27, codechecks
3.3 = py33
3.4 = py34
3.5 = py35

0 comments on commit e9ab2ee

Please sign in to comment.