diff --git a/.gitignore b/.gitignore index efa61ff..6798758 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ dist/* build/* *.pyc doc/build/* -doc/source/api/* \ No newline at end of file +doc/source/api/* +.stestr/ diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..9cc40eb --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ ${TESTS_DIR:-./gerritbot/tests/unit/} $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..06dd412 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,9 @@ +- project: + check: + jobs: + - tox-pep8 + - tox-py27 + gate: + jobs: + - tox-pep8 + - tox-py27 diff --git a/gerritbot/tests/__init__.py b/gerritbot/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gerritbot/tests/unit/__init__.py b/gerritbot/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gerritbot/tests/unit/test_bot.py b/gerritbot/tests/unit/test_bot.py new file mode 100644 index 0000000..3426f8e --- /dev/null +++ b/gerritbot/tests/unit/test_bot.py @@ -0,0 +1,35 @@ +# +# 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 testtools +import yaml + +import gerritbot.bot as bot + +CHANNEL_CONFIG_YAML = """ +openstack-dev: + events: + - patchset-created + - change-merged + projects: + - openstack/nova + - openstack/swift + branches: + - master +""" + + +class ChannelConfigTestCase(testtools.TestCase): + def test_missing_octothorpe(self): + channel_config = bot.ChannelConfig(yaml.load(CHANNEL_CONFIG_YAML)) + self.assertEqual(['#openstack-dev'], channel_config.channels) diff --git a/test-requirements.txt b/test-requirements.txt index bb0ce44..fe3f012 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,5 @@ hacking>=0.10.0,<0.11 sphinx>=1.1.2 +os-testr>=0.8.0 # Apache-2.0 +mock>=2.0.0 # BSD +testtools>=1.4.0 # MIT diff --git a/tox.ini b/tox.ini index 8848b29..03b5f81 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,21 @@ [tox] -envlist = pep8 +envlist = py27,pep8 [testenv] -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +usedevelop = True +install_command = pip install {opts} {packages} +setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE = 1 + LANGUAGE=en_US + LC_ALL=en_US.UTF-8 + PYTHONWARNINGS=default::DeprecationWarning + TESTS_DIR=./gerritbot/tests/unit/ +deps = -r{toxinidir}/test-requirements.txt +whitelist_externals = rm +commands = + rm -f .testrepository/times.dbm + ostestr {posargs} +passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [testenv:pep8]