Add tests
This adds a test for the 'generate_id' method, and all the configuration needed to run tests. Change-Id: Iaf8158da1f96853f3880f1b8e6ade5d466e27c64
This commit is contained in:
parent
8b44f51c01
commit
a4f650e15a
4
.testr.conf
Normal file
4
.testr.conf
Normal file
@ -0,0 +1,4 @@
|
||||
[DEFAULT]
|
||||
test_command=${PYTHON:-python} -m subunit.run discover sphinxcontrib/docbookrestapi/tests $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
@ -1 +1,3 @@
|
||||
docutils
|
||||
pytidylib6
|
||||
sphinx>=1.1.2
|
||||
|
39
sphinxcontrib/docbookrestapi/tests/test_utils.py
Normal file
39
sphinxcontrib/docbookrestapi/tests/test_utils.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Cyril Roelandt <cyril.roelandt@enovance.com>
|
||||
#
|
||||
# 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 unittest
|
||||
|
||||
from sphinxcontrib.docbookrestapi.docbook import generate_id
|
||||
|
||||
|
||||
class TestUtils(unittest.TestCase):
|
||||
def test_generate_id(self):
|
||||
test_cases = [
|
||||
# (path, method, expected_result)
|
||||
('/v2/foos', 'get', 'listFoos'),
|
||||
|
||||
('/v2/foos/foo_id', 'delete', 'deleteFoo'),
|
||||
('/v2/foos/foo_id', 'get', 'showFoo'),
|
||||
('/v2/foos/foo_id', 'post', 'createFoo'),
|
||||
('/v2/foos/foo_id', 'put', 'updateFoo'),
|
||||
|
||||
('/v2/foos/foo_id/bar', 'get', 'showFooBar'),
|
||||
('/v2/foos/foo_id/bar', 'put', 'updateFooBar'),
|
||||
]
|
||||
|
||||
for (path, method, result) in test_cases:
|
||||
self.assertEqual(generate_id(path, method), result)
|
2
test-requirements.txt
Normal file
2
test-requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
discover
|
||||
testrepository>=0.0.17
|
10
tox.ini
10
tox.ini
@ -1,7 +1,15 @@
|
||||
[tox]
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
envlist = pep8
|
||||
envlist = pep8,py26,py27,py33
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
install_command = pip install -U {opts} {packages}
|
||||
usedevelop = True
|
||||
commands =
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
# Install bounded pep8/pyflakes first, then let flake8 install
|
||||
|
Loading…
x
Reference in New Issue
Block a user