removed logging with dictConfig, jenkins and redis code removed
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
from mock import patch, MagicMock
|
||||
from core.api import API
|
||||
from core.api import API, parse_commands_file
|
||||
|
||||
|
||||
TEST_RUN_NAME = 'tempest'
|
||||
@@ -40,3 +40,15 @@ class TestApi(unittest.TestCase):
|
||||
res = api.get_info(TEST_RUN_NAME, TEST_RUN_ID)
|
||||
self.storage.get_test_results.assert_called_once_with(TEST_RUN_ID)
|
||||
|
||||
def test_parse_commands_file(self):
|
||||
res = parse_commands_file()
|
||||
expected = {'tempest': {
|
||||
'argv': '-A "type == [\'sanity\', \'smoke\']"',
|
||||
'driver': 'nose',
|
||||
'test_path': '/root/ostf/ostf-tests'},
|
||||
'tests': {'driver': 'nose',
|
||||
'test_path': '/home/dshulyak/projects/ostf-tests'}
|
||||
}
|
||||
self.assertEqual(res, expected)
|
||||
|
||||
|
||||
|
||||
@@ -20,21 +20,14 @@ class TestNoseAdapters(unittest.TestCase):
|
||||
driver = get_transport('tempest')
|
||||
self.assertIsInstance(driver, nose_adapter.NoseDriver)
|
||||
|
||||
@patch.object(nose_adapter, 'CONF')
|
||||
def test_parse_test_runs(self, conf_mock):
|
||||
conf_mock.test_runs_raw = ['tempest=-A "type == ["sanity", "fuel"]"']
|
||||
res = nose_adapter.get_test_run_args('tempest')
|
||||
self.assertEqual(res, ['-A "type == ["sanity", "fuel"]"'])
|
||||
|
||||
@patch('core.transport.nose_adapter.io.open')
|
||||
@patch.object(nose_adapter, 'CONF')
|
||||
def test_create_tempest_conf(self, conf_mock, io_mock):
|
||||
conf_mock.overwrite_test_conf = True
|
||||
def test_create_tempest_conf(self, io_mock):
|
||||
string_io = DummyStringIO()
|
||||
io_mock.return_value = string_io
|
||||
conf = {'param1': 'test',
|
||||
'param2': 'test'}
|
||||
res = self.nose_driver.prepare_config(conf)
|
||||
conf_path = '/etc/config.conf'
|
||||
res = self.nose_driver.prepare_config(conf, conf_path)
|
||||
self.assertEqual(string_io.getvalue(),
|
||||
u'param2 = test\nparam1 = test\n')
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
from core.storage import redis_storage
|
||||
import unittest
|
||||
import json
|
||||
from nose.tools import nottest
|
||||
|
||||
|
||||
@nottest
|
||||
class TestRedisStorage(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.redis_client = redis_storage.RedisStorage(db=10)
|
||||
_raw = self.redis_client._r
|
||||
unique_keys_container = 'unique'
|
||||
text_run = 'tempest'
|
||||
text_run_id = 1
|
||||
test_id = 'test_simple.Simple'
|
||||
data = json.dumps({'type': 'success'})
|
||||
stored_id = '{}:{}'.format(text_run, text_run_id)
|
||||
_raw.hincrby(unique_keys_container, text_run)
|
||||
_raw.hset(stored_id, test_id, data)
|
||||
_raw.hset(stored_id, 'stats', json.dumps({'passed': 1}))
|
||||
|
||||
def test_add_test_run(self):
|
||||
test_run = 'tempest'
|
||||
expected = 2
|
||||
res = self.redis_client.add_test_run(test_run)
|
||||
self.assertEqual(res, expected)
|
||||
|
||||
def test_get_current_test_run(self):
|
||||
test_run = 'tempest'
|
||||
res = self.redis_client.get_current_test_run(test_run)
|
||||
self.assertEqual(res, '1')
|
||||
|
||||
def test_get_test_results(self):
|
||||
test_run_id = 'tempest:1'
|
||||
expected = {test_run_id: {'test_simple.Simple': {'type': 'success'},
|
||||
'stats': {'passed': 1}}}
|
||||
res = self.redis_client.get_test_results(test_run_id)
|
||||
self.assertEqual(res, expected)
|
||||
|
||||
def test_get_test_result_without_stats(self):
|
||||
test_run_id = 'tempest:1'
|
||||
test_id = 'test_simple.Simple'
|
||||
expected = {test_run_id: {'test_simple.Simple': {'type': 'success'}}}
|
||||
res = self.redis_client.get_test_result(test_run_id, test_id)
|
||||
self.assertEqual(res, expected)
|
||||
|
||||
def test_get_test_result_with_stats(self):
|
||||
test_run_id = 'tempest:1'
|
||||
test_id = 'test_simple.Simple'
|
||||
expected = {test_run_id: {'test_simple.Simple': {'type': 'success'},
|
||||
'stats': {'passed': 1}}}
|
||||
res = self.redis_client.get_test_result(test_run_id, test_id, stats=True)
|
||||
self.assertEqual(res, expected)
|
||||
|
||||
def test_add_test_result(self):
|
||||
test_run_id = 'tempest:1'
|
||||
test_id = 'test_simple.SecondSimple'
|
||||
data = json.dumps({'type': 'failure'})
|
||||
res = self.redis_client.add_test_result(test_run_id, test_id, data)
|
||||
self.assertEqual(res, 1)
|
||||
|
||||
def tearDown(self):
|
||||
self.redis_client.flush_db()
|
||||
Reference in New Issue
Block a user