From c3ee071d73f4719ac5313303d4898c8bc41ea921 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Thu, 24 Jan 2013 09:42:57 -0800 Subject: [PATCH] Make it possible for openstack-CI to run tests Per http://wiki.openstack.org/ProjectTestingInterface we enable all of the commands except build_sphinx because we do not have any sphinx documentation as of yet. Includes babel support though there are no properly internationalized strings just yet. Change-Id: Iae6e6b3f9e605106f4575196fa5527d2187255df --- .gitignore | 3 ++ MANIFEST.in | 7 +++ babel.cfg | 1 + diskimage_builder/elements.py | 1 - .../locale/diskimage_builder.pot | 20 +++++++++ .../en/LC_MESSAGES/diskimage_builder.po | 20 +++++++++ diskimage_builder/test_elementdeps.py | 15 ++++--- diskimage_builder/test_elements.py | 5 ++- setup.cfg | 13 ++++++ setup.py | 40 +++++++++++++++++ tools/test-requires | 2 + tox.ini | 43 +++++++++++++++++++ 12 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 MANIFEST.in create mode 100644 babel.cfg create mode 100644 diskimage_builder/locale/diskimage_builder.pot create mode 100644 diskimage_builder/locale/en/LC_MESSAGES/diskimage_builder.po create mode 100644 setup.cfg create mode 100755 setup.py create mode 100644 tools/test-requires create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 11571660..4a919ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ .testrepository *.swp *.pyc +.tox +*.egg-info +dist diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..daceefe7 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +recursive-include lib +include bin/disk-image-create +include bin/disk-image-get-kernel +include bin/ramdisk-image-create +recursive-include elements +include README.md +recursive-include docs diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 00000000..efceab81 --- /dev/null +++ b/babel.cfg @@ -0,0 +1 @@ +[python: **.py] diff --git a/diskimage_builder/elements.py b/diskimage_builder/elements.py index 1029854b..3002a919 100644 --- a/diskimage_builder/elements.py +++ b/diskimage_builder/elements.py @@ -86,6 +86,5 @@ def main(argv): print(' '.join(expand_dependencies(args.elements))) return 0 - sys.stderr.write("ERROR: please choose an option.\n") return -1 diff --git a/diskimage_builder/locale/diskimage_builder.pot b/diskimage_builder/locale/diskimage_builder.pot new file mode 100644 index 00000000..a2f51770 --- /dev/null +++ b/diskimage_builder/locale/diskimage_builder.pot @@ -0,0 +1,20 @@ +# Translations template for configapplier. +# Copyright (C) 2013 ORGANIZATION +# This file is distributed under the same license as the configapplier +# project. +# FIRST AUTHOR , 2013. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: configapplier 0.0.1\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2013-01-24 09:27-0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.6\n" + diff --git a/diskimage_builder/locale/en/LC_MESSAGES/diskimage_builder.po b/diskimage_builder/locale/en/LC_MESSAGES/diskimage_builder.po new file mode 100644 index 00000000..8023eed6 --- /dev/null +++ b/diskimage_builder/locale/en/LC_MESSAGES/diskimage_builder.po @@ -0,0 +1,20 @@ +# English translations for configapplier. +# Copyright (C) 2013 ORGANIZATION +# This file is distributed under the same license as the configapplier +# project. +# FIRST AUTHOR , 2013. +# +msgid "" +msgstr "" +"Project-Id-Version: configapplier 0.0.1\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2013-01-24 09:27-0800\n" +"PO-Revision-Date: 2013-01-24 09:41-0800\n" +"Last-Translator: FULL NAME \n" +"Language-Team: en \n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.6\n" + diff --git a/diskimage_builder/test_elementdeps.py b/diskimage_builder/test_elementdeps.py index 6cb4a7e5..a62a66f3 100644 --- a/diskimage_builder/test_elementdeps.py +++ b/diskimage_builder/test_elementdeps.py @@ -20,7 +20,9 @@ from fixtures import Fixture, TempDir from diskimage_builder.elements import expand_dependencies -data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test-elements')) +data_dir = os.path.abspath( + os.path.join(os.path.dirname(__file__), 'test-elements')) + def _populate_element(element_dir, element_name, element_deps=[]): element_home = os.path.join(element_dir, element_name) @@ -29,6 +31,7 @@ def _populate_element(element_dir, element_name, element_deps=[]): with open(deps_path, 'w') as deps_file: deps_file.write("\n".join(element_deps)) + class TestElementDeps(TestCase): def setUp(self): @@ -45,27 +48,27 @@ class TestElementDeps(TestCase): def test_non_transitive_deps(self): result = expand_dependencies(['requires-foo'], - elements_dir=self.element_dir) + elements_dir=self.element_dir) self.assertEquals(set(['requires-foo', 'foo']), result) def test_transitive_deps(self): result = expand_dependencies(['requires-requires-foo'], - elements_dir=self.element_dir) + elements_dir=self.element_dir) self.assertEquals(set(['requires-requires-foo', 'requires-foo', 'foo']), result) def test_no_deps(self): result = expand_dependencies(['foo'], - elements_dir=self.element_dir) + elements_dir=self.element_dir) self.assertEquals(set(['foo']), result) def test_self(self): result = expand_dependencies(['self'], - elements_dir=self.element_dir) + elements_dir=self.element_dir) self.assertEquals(set(['self']), result) def test_circular(self): result = expand_dependencies(['circular1'], - elements_dir=self.element_dir) + elements_dir=self.element_dir) self.assertEquals(set(['circular1', 'circular2']), result) diff --git a/diskimage_builder/test_elements.py b/diskimage_builder/test_elements.py index 1a626533..1668b8a9 100644 --- a/diskimage_builder/test_elements.py +++ b/diskimage_builder/test_elements.py @@ -17,7 +17,10 @@ import os import sys import unittest -class StubPackage: pass + +class StubPackage: + pass + # conceptually load_tests should be in __init__, but see # http://bugs.python.org/issue16662 instead. So, its here in test_elements.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..20daa6e6 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,13 @@ +[extract_messages] +keywords = _ gettext ngettext l_ lazy_gettext +mapping_file = babel.cfg +output_file = diskimage_builder/locale/diskimage_builder.pot + +[update_catalog] +domain = diskimage_builder +output_dir = diskimage_builder/locale +input_file = diskimage_builder/locale/diskimage_builder.pot + +[compile_catalog] +directory = diskimage_builder/locale +domain = diskimage_builder diff --git a/setup.py b/setup.py new file mode 100755 index 00000000..da110c5a --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# +# 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 setuptools + +with open("README.md", 'rt') as readme: + readme_text = readme.read() + +setuptools.setup( + name='diskimage_builder', + version='0.0.1', + description="""Build Disk Images for use on OpenStack Nova""", + long_description = readme_text, + license='Apache License (2.0)', + author='HP Cloud Services', + author_email='nobody@hp.com', + url='https://github.com/stackforge/diskimage-builder', + packages=setuptools.find_packages(), + include_package_data=True, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 2.7', + 'Environment :: Console', + ], + scripts=['bin/element-info'], + py_modules=[]) diff --git a/tools/test-requires b/tools/test-requires new file mode 100644 index 00000000..0cf0fc18 --- /dev/null +++ b/tools/test-requires @@ -0,0 +1,2 @@ +testtools +fixtures diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..ef07a1a4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,43 @@ +[tox] +envlist = py26,py27,pep8 + +[testenv] +setenv = LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C +deps= + testtools + testrepository + coverage + babel +commands= + bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi' + bash -c 'testr run --parallel {posargs} ; RET=$? echo "Slowest Tests" ; testr slowest && exit $RET' + +[testenv:py26] +deps= + testtools + testrepository + coverage + babel + discover + argparse + +[pep8] +ignore = E125 + +[testenv:pep8] +deps = pep8 +commands = + pep8 --repeat --show-source --exclude=.venv,.tox,doc . + +[testenv:venv] +commands = {posargs} + +[testenv:cover] +setenv = PYTHON=coverage run --source diskimage_builder +commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi' + bash -c 'testr run --parallel ; RET=$? ; coverage combine ; coverage html -d ./cover $OMIT && exit $RET' + +[tox:jenkins] +downloadcache = ~/cache/pip