Add unit test framework and one unit test
Add an initial unit test framework and one unit test. This way we can ask people to add unit tests when they contribute code. Change-Id: If52976e1992945a8e38af3cbad5b5f4389922d4c
This commit is contained in:
parent
7050c81714
commit
4658934d22
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ dist/*
|
||||
build/*
|
||||
*.pyc
|
||||
doc/build/*
|
||||
doc/source/api/*
|
||||
doc/source/api/*
|
||||
.stestr/
|
||||
|
4
.testr.conf
Normal file
4
.testr.conf
Normal file
@ -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
|
9
.zuul.yaml
Normal file
9
.zuul.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- tox-pep8
|
||||
- tox-py27
|
||||
gate:
|
||||
jobs:
|
||||
- tox-pep8
|
||||
- tox-py27
|
0
gerritbot/tests/__init__.py
Normal file
0
gerritbot/tests/__init__.py
Normal file
0
gerritbot/tests/unit/__init__.py
Normal file
0
gerritbot/tests/unit/__init__.py
Normal file
35
gerritbot/tests/unit/test_bot.py
Normal file
35
gerritbot/tests/unit/test_bot.py
Normal file
@ -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)
|
@ -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
|
||||
|
18
tox.ini
18
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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user