summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john.l.villalovos@intel.com>2017-08-30 15:40:41 -0700
committerJohn L. Villalovos <openstack.org@sodarock.com>2018-02-05 12:59:39 -0800
commit4658934d2239c32103c0e04cb32e2af4d44c16f4 (patch)
tree399a772aa2ab5dafe602cba964fb8131958b110f
parent7050c8171477b65bd6b2797d6fc3772bc45f7288 (diff)
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
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: Joshua Hesketh <josh@nitrotech.org> Workflow+1: Joshua Hesketh <josh@nitrotech.org> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 06 Feb 2018 02:03:32 +0000 Reviewed-on: https://review.openstack.org/499377 Project: openstack-infra/gerritbot Branch: refs/heads/master
-rw-r--r--.gitignore3
-rw-r--r--.testr.conf4
-rw-r--r--.zuul.yaml9
-rw-r--r--gerritbot/tests/__init__.py0
-rw-r--r--gerritbot/tests/unit/__init__.py0
-rw-r--r--gerritbot/tests/unit/test_bot.py35
-rw-r--r--test-requirements.txt3
-rw-r--r--tox.ini18
8 files changed, 68 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index efa61ff..6798758 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ dist/*
7build/* 7build/*
8*.pyc 8*.pyc
9doc/build/* 9doc/build/*
10doc/source/api/* \ No newline at end of file 10doc/source/api/*
11.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 @@
1[DEFAULT]
2test_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
3test_id_option=--load-list $IDFILE
4test_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 @@
1- project:
2 check:
3 jobs:
4 - tox-pep8
5 - tox-py27
6 gate:
7 jobs:
8 - tox-pep8
9 - tox-py27
diff --git a/gerritbot/tests/__init__.py b/gerritbot/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gerritbot/tests/__init__.py
diff --git a/gerritbot/tests/unit/__init__.py b/gerritbot/tests/unit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gerritbot/tests/unit/__init__.py
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 @@
1#
2# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14import testtools
15import yaml
16
17import gerritbot.bot as bot
18
19CHANNEL_CONFIG_YAML = """
20openstack-dev:
21 events:
22 - patchset-created
23 - change-merged
24 projects:
25 - openstack/nova
26 - openstack/swift
27 branches:
28 - master
29"""
30
31
32class ChannelConfigTestCase(testtools.TestCase):
33 def test_missing_octothorpe(self):
34 channel_config = bot.ChannelConfig(yaml.load(CHANNEL_CONFIG_YAML))
35 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 @@
1hacking>=0.10.0,<0.11 1hacking>=0.10.0,<0.11
2sphinx>=1.1.2 2sphinx>=1.1.2
3os-testr>=0.8.0 # Apache-2.0
4mock>=2.0.0 # BSD
5testtools>=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 @@
1[tox] 1[tox]
2envlist = pep8 2envlist = py27,pep8
3 3
4[testenv] 4[testenv]
5deps = -r{toxinidir}/requirements.txt 5usedevelop = True
6 -r{toxinidir}/test-requirements.txt 6install_command = pip install {opts} {packages}
7setenv = VIRTUAL_ENV={envdir}
8 PYTHONDONTWRITEBYTECODE = 1
9 LANGUAGE=en_US
10 LC_ALL=en_US.UTF-8
11 PYTHONWARNINGS=default::DeprecationWarning
12 TESTS_DIR=./gerritbot/tests/unit/
13deps = -r{toxinidir}/test-requirements.txt
14whitelist_externals = rm
15commands =
16 rm -f .testrepository/times.dbm
17 ostestr {posargs}
18passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
7 19
8 20
9[testenv:pep8] 21[testenv:pep8]