diff --git a/.gitignore b/.gitignore index 5cba9f5b..b01c1448 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ candidates/tc.rst candidates/events.rst .projects*yaml .projects*.pkl +.testrepository diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..b8ea5bce --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ + ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./openstack_election/tests} $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/openstack_election/__init__.py b/openstack_election/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tools/check_candidacy.py b/openstack_election/check_candidacy.py similarity index 98% rename from tools/check_candidacy.py rename to openstack_election/check_candidacy.py index f2c4a38c..6d26dd55 100755 --- a/tools/check_candidacy.py +++ b/openstack_election/check_candidacy.py @@ -17,7 +17,7 @@ from __future__ import unicode_literals import datetime import os -import utils +from openstack_election import utils # FIXME: Printing from library function isn't great. diff --git a/openstack_election/cmds/__init__.py b/openstack_election/cmds/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tools/check-new-candidacy.py b/openstack_election/cmds/check_all_candidacies.py similarity index 94% rename from tools/check-new-candidacy.py rename to openstack_election/cmds/check_all_candidacies.py index 046005ce..4f24f32e 100755 --- a/tools/check-new-candidacy.py +++ b/openstack_election/cmds/check_all_candidacies.py @@ -1,5 +1,3 @@ -#!/usr/bin/env 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 @@ -17,10 +15,9 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import sys -import check_candidacy -import utils +from openstack_election import check_candidacy +from openstack_election import utils def get_reviews(): @@ -63,7 +60,3 @@ def main(): print('[E]: %s is not a valid candidate\n\n' % (owner['email'])) return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/check-candidacy.py b/openstack_election/cmds/check_candidacy.py similarity index 94% rename from tools/check-candidacy.py rename to openstack_election/cmds/check_candidacy.py index 0e308217..e78a837b 100755 --- a/tools/check-candidacy.py +++ b/openstack_election/cmds/check_candidacy.py @@ -1,5 +1,3 @@ -#!/usr/bin/env 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 @@ -17,10 +15,9 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import sys -import check_candidacy -import utils +from openstack_election import check_candidacy +from openstack_election import utils def main(): @@ -55,6 +52,3 @@ def main(): else: print('[E]: %s is not a valid candidate\n\n' % (owner['email'])) return 1 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/openstack_election/tests/__init__.py b/openstack_election/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack_election/tests/test_utils.py b/openstack_election/tests/test_utils.py new file mode 100644 index 00000000..58bec26e --- /dev/null +++ b/openstack_election/tests/test_utils.py @@ -0,0 +1,34 @@ +# 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. + +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + +import testtools + +import openstack_election.utils + + +class TestGerritUtils(testtools.TestCase): + def test_candidate_files(self): + review = {'revisions': { + 'Ifake': { + 'files': { + 'some/file': {}, + 'candidates/some/file': {}} + } + } + } + + self.assertEqual(openstack_election.utils.candidate_files(review), + ['candidates/some/file']) diff --git a/tools/utils.py b/openstack_election/utils.py similarity index 100% rename from tools/utils.py rename to openstack_election/utils.py diff --git a/setup.cfg b/setup.cfg index c3f229c5..78799ba1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,28 @@ [metadata] name = openstack-election -version = 11.0 summary = OpenStack Election Documents description-file = README.rst author = OpenStack Election Officials author-email = openstack-dev@lists.openstack.org home-page = http://www.openstack.org/ +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + +[files] +packages = openstack_election + +[entry_points] +console_scripts = + check-all-candidacies = openstack_election.cmds.check_all_candidacies:check_reviews + check-candidacy = openstack_election.cmds.check_candidacy:main + [build_sphinx] all_files = 1 diff --git a/test-requirements.txt b/test-requirements.txt index def134b0..7f107c12 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,3 +6,7 @@ sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 flake8>=2.5.4,<2.6.0 # MIT yamllint +mock>=2.0 # BSD +oslotest>=1.10.0 # Apache-2.0 +testrepository>=0.0.18 # Apache-2.0/BSD +testresources>=0.2.4 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index bda5da2c..95f18864 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -envlist = docs,linters -minversion = 1.6 +envlist = docs,linters,py34,py27 +minversion = 2.0 skipsdist = True [testenv] @@ -9,6 +9,10 @@ install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +# NOTE: If py34 fails with "db type could not be determined", delete +# .testrepository and try again. Running py34 before py27 is OK, but not the +# other way around. See: https://bugs.launchpad.net/testrepository/+bug/1212909 +commands = python setup.py testr --slowest --testr-args="{posargs}" [testenv:linters] commands = yamllint events.yaml