From fdbb15848f81abfbb6dac5b757a6dac4dc35896c Mon Sep 17 00:00:00 2001 From: Saad Zaher Date: Mon, 9 May 2016 15:00:10 +0000 Subject: [PATCH] Adding pep8, pylint, coverage, sphinx testing --- .coveragerc | 13 + .gitignore | 28 ++- .pylintrc | 333 ++++++++++++++++++++++++++ .testr.conf | 9 + AUTHORS | 6 - ChangeLog | 22 -- doc/.gitignore | 3 + doc/source/conf.py | 265 ++++++++++++++++++++ doc/source/index.rst | 21 ++ setup.cfg | 6 +- test-requirements.txt | 17 ++ tests/__init__.py | 1 + tests/unit/__init__.py | 1 + tests/unit/common/__init__.py | 1 + tests/unit/common/test_yaml_parser.py | 39 +++ tests/unit/evacuattors/__init__.py | 1 + tests/unit/fencers/__init__.py | 1 + tests/unit/monitors/__init__.py | 1 + tests/unit/notifiers/__init__.py | 1 + tox.ini | 71 ++++++ 20 files changed, 807 insertions(+), 33 deletions(-) create mode 100644 .coveragerc create mode 100644 .pylintrc create mode 100644 .testr.conf delete mode 100644 AUTHORS delete mode 100644 ChangeLog create mode 100644 doc/.gitignore create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst create mode 100644 test-requirements.txt create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/common/__init__.py create mode 100644 tests/unit/common/test_yaml_parser.py create mode 100644 tests/unit/evacuattors/__init__.py create mode 100644 tests/unit/fencers/__init__.py create mode 100644 tests/unit/monitors/__init__.py create mode 100644 tests/unit/notifiers/__init__.py create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..d0bed96 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +# .coveragerc to control coverage.py +[run] +branch = True +omit = tests/coverage/* + +[path] +source = freezer_dr + +[html] +directory = term + +[report] +ignore_errors = True diff --git a/.gitignore b/.gitignore index 9fbf606..a4f688c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,24 @@ -*.pyc -*.egg/ -*.egg-info/ -build/ +__pycache__ +dist +build +.venv +.idea +.autogenerated +.coverage +cover/ +coverage.xml +*.sw? +.tox +*.egg +*.egg-info +*.py[co] +.DS_Store +*.log +.testrepository +subunit.log +.eggs +AUTHORS +ChangeLog + +# Coverage data +.coverage.* diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..8fd2a13 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,333 @@ +[MASTER] + +# Specify a configuration file. +#rcfile= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Profiled execution. +profile=no + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Pickle collected data for later comparisons. +persistent=no + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# DEPRECATED +include-ids=no + +# DEPRECATED +symbols=no + + +[MESSAGES CONTROL] + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time. See also the "--disable" option for examples. +#enable= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=W,C,R + + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html. You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells whether to display a full report or only the messages +reports=no + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Add a comment according to your evaluation note. This is used by the global +# evaluation report (RP0004). +comment=no + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus extisting member attributes cannot be deduced by static analysis +ignored-modules=distutils + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +ignored-classes=SQLObject + +# When zope mode is activated, add a predefined set of Zope acquired attributes +# to generated-members. +zope=no + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. Python regular +# expressions are accepted. +generated-members=REQUEST,acl_users,aq_parent + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[BASIC] + +# Required attributes for module, separated by a comma +required-attributes= + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input,file + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# Regular expression matching correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for function names +function-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for variable names +variable-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct constant names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Naming hint for constant names +const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression matching correct attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for attribute names +attr-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for argument names +argument-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression matching correct class attribute names +class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ + +# Naming hint for class attribute names +class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ + +# Regular expression matching correct inline iteration names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Naming hint for inline iteration names +inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ + +# Regular expression matching correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Naming hint for class names +class-name-hint=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression matching correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Naming hint for module names +module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression matching correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Naming hint for method names +method-name-hint=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=__.*__ + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=_$|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=80 + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + +# List of optional constructs for which whitespace checking is disabled +no-space-check=trailing-comma,dict-separator + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..752a278 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,9 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \ + ${PYTHON:-python} -m subunit.run discover -s ${OS_TEST_PATH:-./tests/unit} -t . $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list +group_regex=([^\.]+\.)+ diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index d7e5447..0000000 --- a/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -Jonas Pfannschmidt -Pierre-Arthur MATHIEU -Project Creator -Saad Zaher -Stefano Canepa -Zuul diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 8016615..0000000 --- a/ChangeLog +++ /dev/null @@ -1,22 +0,0 @@ -CHANGES -======= - -* Dummy evacuator and monitor driver for testing -* Adding CREDITS.rst -* Adding Osha description and enhancing templates Fixing some template issues and adding osha description and how it works -* Some small improvements to pass pep8 and pep257 -* Add oslo.log dependency in requirements.txt -* Adding HACKING.rst to follow Openstack Guidelines -* Adding Notification System and Notification Drivers Support sending notification emails in case of any problem happened -* Evacuation is working now and node will be evacuated but ? We need to contact nova guys to ask why when we disable or enable a node the node state is always going up even if the node is powereded off. We had to wait and retry many times for 1 minute at least to give nova compute sometime to update nova api with it's state -* Buidling a plugable evacuators - still need some work ! -* Fixing keystone Configuration adding keystone_authtoken to config file and remove keystone old section -* Add disable node to osclient -* Adding libvirt Fencer driver -* Fixing typo fencor > fencer -* Modified diagrams -* Adding Fencing plugable system -* Adding support for plugable monitoring systems adding support for pbr restructuring osha -* Big Bang -* Add diagram -* Added .gitreview diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..4c2e299 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,3 @@ +build/ +source/ref/ +source/api/ diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..3c7bd68 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,265 @@ +# -*- coding: utf-8 -*- +# +# Freezer documentation build configuration file, created by +# sphinx-quickstart on Thu Feb 4 22:27:35 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +from freezer_dr import __version__ as FREEZER_DR_VERSION + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.viewcode', + 'oslosphinx'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Freezer' +copyright = u'2016, OpenStack' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = FREEZER_DR_VERSION +# The full version, including alpha/beta/rc tags. +release = FREEZER_DR_VERSION + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Freezerdrdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'Freezerdr.tex', u'Freezer DR Documentation', + u'OpenStack', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'freezer-dr', u'Freezer DR Documentation', + [u'OpenStack'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Freezer DR', u'Freezer Disaster Recovery Documentation', + u'OpenStack', 'Freezer Disaster Recovery', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..55db2db --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,21 @@ +.. Freezer Disaster Recovery documentation master file, created by + sphinx-quickstart on Thu Feb 4 22:27:35 2016. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Freezer's Disaster Recovery documentation! +===================================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/setup.cfg b/setup.cfg index a8af165..2d9eb60 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = Freezer DR +name = freezer-dr version = 0.1 summary = OpenStack Disaster Recovery description-file = @@ -25,6 +25,10 @@ packages = setup-hooks = pbr.hooks.setup_hook +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 [pbr] warnerrors = True diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..3a42bae --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,17 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +astroid===1.3.6 +flake8==2.2.4 +hacking>=0.10.0,<0.11 +coverage>=3.6 +discover # BSD +mock>=1.0,<1.1.0 +pep8==1.5.7 +mccabe==0.2.1 # MIT License +pylint==1.4.4 # GNU GPL v2 +python-subunit>=0.0.18 +pyflakes==0.8.1 +testrepository>=0.0.18 +testtools>=0.9.36,!=1.2.0,<2.0.0 + diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/common/__init__.py b/tests/unit/common/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/common/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/common/test_yaml_parser.py b/tests/unit/common/test_yaml_parser.py new file mode 100644 index 0000000..5c8a0a8 --- /dev/null +++ b/tests/unit/common/test_yaml_parser.py @@ -0,0 +1,39 @@ +# (c) Copyright 2014,2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest +from mock import patch + +from freezer_dr.common import utils +from freezer_dr.common.osclient import OSClient + + +class TestUtils(unittest.TestCase): + + @patch('freezer_dr.common.utils.CONF') + def test_os_credentials(self, mock_CONF): + keystone_conf = dict({ + 'auth_url': '', + 'password': '', + 'project_name': '', + 'user_domain_id': '', + 'project_domain_id': '', + 'project_domain_id': '', + 'user_domain_name': '', + 'kwargs': '' + }) + mock_CONF = {'keystone_authtoken': keystone_conf} + cred = utils.get_os_client() + osclient_object = isinstance(cred, OSClient) + self.assertEqual(osclient_object, True, '') diff --git a/tests/unit/evacuattors/__init__.py b/tests/unit/evacuattors/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/evacuattors/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/fencers/__init__.py b/tests/unit/fencers/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/fencers/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/monitors/__init__.py b/tests/unit/monitors/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/monitors/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tests/unit/notifiers/__init__.py b/tests/unit/notifiers/__init__.py new file mode 100644 index 0000000..f920945 --- /dev/null +++ b/tests/unit/notifiers/__init__.py @@ -0,0 +1 @@ +__author__ = 'saad' diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b9ce1c5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,71 @@ +[tox] +envlist = py27,py34,pep8,pylint,docs +skipsdist = True + +[testenv] +usedevelop = True +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +passenv = + FREEZER_TEST_OS_TENANT_NAME + FREEZER_TEST_OS_USERNAME + FREEZER_TEST_OS_REGION_NAME + FREEZER_TEST_OS_PASSWORD + FREEZER_TEST_OS_AUTH_URL + http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY + +install_command = pip install -U {opts} {packages} +setenv = VIRTUAL_ENV={envdir} + +whitelist_externals = + find + coverage + rm + +python_files = test_*.py +norecursedirs = .tox .venv + +[testenv:venv] +commands = {posargs} + +[testenv:py27] +basepython = python2.7 +setenv = + OS_TEST_PATH = ./tests/unit +commands = + find . -type f -name "*.pyc" -delete + python setup.py testr --coverage --testr-args="{posargs}" +# coverage report -m + rm -f .coverage + rm -rf .testrepository + +[testenv:py34] +basepython = python3.4 +setenv = + OS_TEST_PATH = ./tests/unit +commands = + find . -type f -name "*.pyc" -delete + python setup.py testr --coverage --testr-args="{posargs}" +# coverage report -m + rm -f .coverage + rm -rf .testrepository + +[testenv:pep8] +commands = flake8 freezer_dr + +[testenv:pylint] +commands = pylint --rcfile .pylintrc freezer_dr + +[flake8] +# it's not a bug that we aren't using all of hacking +# H102 -> apache2 license exists +# H103 -> license is apache +# H201 -> no bare excepts +# H501 -> don't use locals() for str formatting +# H903 -> \n not \r\n +ignore = H +select = H102, H103, H201, H501, H903, H201, H306, H301, H233 +show-source = True +exclude = .venv,.tox,dist,doc,test,*egg,tests \ No newline at end of file