fix 'make check'

Apply various fixes that arose from test case code rot. These tests will now be
used to verify patches submitted to gerrit, so they need to be up to par.

Change-Id: I5277be0c434226d9d02e038f0bc72fd2557350c1
Related: OS#2215
This commit is contained in:
Neels Hofmeyr 2017-04-27 19:48:09 +02:00
parent ac45a22356
commit 2694a9d329
8 changed files with 26 additions and 14 deletions

View File

@ -17,7 +17,7 @@ bts:
ipa_unit_id: 5
addr: 10.42.42.115
band: GSM-1800
trx:
trx_list:
- hw_addr: 00:0c:90:32:b5:8a
- label: nanoBTS 1900
@ -25,7 +25,7 @@ bts:
ipa_unit_id: 1902
addr: 10.42.42.190
band: GSM-1900
trx:
trx_list:
- hw_addr: 00:02:95:00:41:b3
arfcn:

View File

@ -14,7 +14,7 @@ example_config_file = 'test.cfg'
example_config = os.path.join(_prep.script_dir, 'config_test', example_config_file)
cfg = config.read(example_config)
pprint.pprint(cfg)
pprint.pprint(cfg, width=81)
test_schema = {
'modems[].dbus_path': schema.STR,

View File

@ -51,14 +51,14 @@ ok, caused exception: RuntimeError('Refusing to drop a list of resources from it
'band': 'GSM-1800',
'ipa_unit_id': '5',
'label': 'octBTS 3000',
'trx': [{'hw_addr': '00:0c:90:32:b5:8a'}],
'trx_list': [{'hw_addr': '00:0c:90:32:b5:8a'}],
'type': 'oct'},
{'_hash': '0b7fabd512b36aec43d7d496abd00af4e193b0f8',
'addr': '10.42.42.190',
'band': 'GSM-1900',
'ipa_unit_id': '1902',
'label': 'nanoBTS 1900',
'trx': [{'hw_addr': '00:02:95:00:41:b3'}],
'trx_list': [{'hw_addr': '00:02:95:00:41:b3'}],
'type': 'nanobts'}],
'modem': [{'_hash': '19c69e45aa090fb511446bd00797690aa82ff52f',
'imsi': '901700000007801',
@ -168,7 +168,7 @@ ok, caused exception: RuntimeError('Refusing to drop a list of resources from it
band: GSM-1800
ipa_unit_id: '5'
label: octBTS 3000
trx:
trx_list:
- hw_addr: 00:0c:90:32:b5:8a
type: oct
--- (want='modem'): DBG: Looking for 2 x modem , candidates: 16
@ -209,7 +209,7 @@ bts:
band: GSM-1800
ipa_unit_id: '5'
label: octBTS 3000
trx:
trx_list:
- hw_addr: 00:0c:90:32:b5:8a
type: oct
modem:

View File

@ -16,7 +16,10 @@ resources:
- times: '1'
- run hello world test
tst test_suite: Suite run start
tst test_suite: reserving resources...
tst test_suite: DBG: {combining='resources'} [test_suite↪test_suite]
tst test_suite: DBG: {definition_conf={bts=[{'times': '1'}], modem=[{'times': '2'}], nitb_iface=[{'times': '1'}]}} [test_suite↪(combining_scenarios='resources')↪test_suite]
--- (want='bts'): DBG: Looking for 1 x bts , candidates: 3
--- (want='bts'): DBG: Picked - _hash: 07d9c8aaa940b674efcbbabdd69f58a6ce4e94f9
addr: 10.42.42.114
@ -48,6 +51,7 @@ tst hello_world.py: PASS [test_suite↪hello_world.py]
pass: all 1 tests passed.
- a test with an error
tst test_suite: Suite run start [suite.py:191]
tst test_error.py: START [test_suite↪test_error.py] [suite.py:96]
tst test_error.py:3: I am 'test_suite' / 'test_error.py:3' [test_suite↪test_error.py:3] [test_error.py:3]
tst test_error.py:5: FAIL [test_suite↪test_error.py:5] [suite.py:108]

View File

@ -20,7 +20,7 @@ assert(isinstance(s_def, suite.SuiteDefinition))
print(config.tostr(s_def.conf))
print('- run hello world test')
s = suite.SuiteRun(None, s_def)
s = suite.SuiteRun(None, 'test_suite', s_def)
results = s.run_tests('hello_world.py')
print(str(results))

View File

@ -17,7 +17,7 @@ bts:
ipa_unit_id: 5
addr: 10.42.42.115
band: GSM-1800
trx:
trx_list:
- hw_addr: 00:0c:90:32:b5:8a
- label: nanoBTS 1900
@ -25,7 +25,7 @@ bts:
ipa_unit_id: 1902
addr: 10.42.42.190
band: GSM-1900
trx:
trx_list:
- hw_addr: 00:02:95:00:41:b3
arfcn:

View File

@ -19,7 +19,7 @@ mock_timeslot_list=(
)
mock_bts = {
'type': 'val_type',
'osmobsc_bts_type': 'val_type',
'band': 'val_band',
'location_area_code': 'val_bts.location_area_code',
'base_station_id_code': 'val_bts.base_station_id_code',

View File

@ -24,6 +24,8 @@ import traceback
import contextlib
from inspect import getframeinfo, stack
from .util import is_dict
L_ERR = 30
L_LOG = 20
L_DBG = 10
@ -512,14 +514,20 @@ def run_logging_exceptions(func, *func_args, return_on_failure=None, **func_kwar
log_exn()
return return_on_failure
def _compose_named_items(item):
'make sure dicts are output sorted, for test expectations'
if is_dict(item):
return '{%s}' % (', '.join(
['%s=%s' % (k, _compose_named_items(v))
for k,v in sorted(item.items())]))
return repr(item)
def compose_message(messages, named_items):
msgs = [str(m) for m in messages]
if named_items:
# unfortunately needs to be sorted to get deterministic results
msgs.append('{%s}' %
(', '.join(['%s=%r' % (k,v)
for k,v in sorted(named_items.items())])))
msgs.append(_compose_named_items(named_items))
return ' '.join(msgs)