Create test framework for python with stestr.
Add add the first unit test for fm-rest-api/fm/fm/common/timeutils. Add tox task for py27/35 as zuul checking and gating jobs. Story: 2007082 Task: 38077 Change-Id: I2f259dcf2178f42546966063c0d724bc17e2a804 Signed-off-by: chenyan <yan.chen@intel.com>changes/75/702175/12
parent
3a58bf68a1
commit
385f274a8f
@ -0,0 +1,5 @@
|
||||
[DEFAULT]
|
||||
test_path=./fm/tests
|
||||
top_dir=./
|
||||
#parallel_class=True
|
||||
|
@ -0,0 +1,14 @@
|
||||
# Copyright 2020 Intel Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
@ -0,0 +1,33 @@
|
||||
# Copyright 2020 Intel Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Base classes for our unit tests.
|
||||
|
||||
Allows overriding of config for use of fakes, and some black magic for
|
||||
inline callbacks.
|
||||
|
||||
"""
|
||||
import testtools
|
||||
|
||||
|
||||
class TestCase(testtools.TestCase):
|
||||
"""Test case base class for all unit tests."""
|
||||
|
||||
def setUp(self):
|
||||
"""Run before each test method to initialize test environment."""
|
||||
super(TestCase, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestCase, self).tearDown()
|
@ -0,0 +1,34 @@
|
||||
# Copyright 2020 Intel Corporation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 datetime
|
||||
from fm.common import timeutils
|
||||
|
||||
from fm.tests import base
|
||||
|
||||
|
||||
class FaultTimeUtilsTestCase(base.TestCase):
|
||||
|
||||
def test_isotime(self):
|
||||
isotimestr = timeutils.isotime()
|
||||
isotime = timeutils.parse_isotime(isotimestr)
|
||||
self.assertTrue(isinstance(isotime, datetime.datetime))
|
||||
|
||||
isotimestr = timeutils.isotime(subsecond=True)
|
||||
isotime = timeutils.parse_isotime(isotimestr)
|
||||
self.assertTrue(isinstance(isotime, datetime.datetime))
|
||||
|
||||
self.assertRaises(ValueError, timeutils.parse_isotime, "bad input")
|
||||
self.assertRaises(ValueError, timeutils.parse_isotime, isotime)
|
@ -1 +1,10 @@
|
||||
-r requirements.txt
|
||||
hacking!=0.13.0,<0.14,>=0.12.0
|
||||
bashate >= 0.2
|
||||
PyYAML >= 3.1.0
|
||||
yamllint >= 0.5.2
|
||||
stestr
|
||||
testtools!=1.2.0,>=0.9.36
|
||||
iso8601
|
||||
stestr
|
||||
mock
|
||||
cython
|
||||
|
@ -0,0 +1,33 @@
|
||||
[tox]
|
||||
envlist = py27,py35
|
||||
minversion = 2.3
|
||||
skipsdist = True
|
||||
stxdir = {toxinidir}/../../../
|
||||
|
||||
[testenv]
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
OS_STDOUT_CAPTURE=1
|
||||
OS_STDERR_CAPTURE=1
|
||||
OS_TEST_TIMEOUT=60
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:py27]
|
||||
basepython = python2.7
|
||||
commands =
|
||||
stestr run {posargs}
|
||||
stestr slowest
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
commands =
|
||||
stestr run {posargs}
|
||||
stestr slowest
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue