2017-03-28 10:16:58 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import _prep
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
from osmo_gsm_tester import template, log
|
|
|
|
|
|
|
|
log.set_level(log.C_CNF, log.L_DBG)
|
|
|
|
|
|
|
|
print('- Testing: fill a config file with values')
|
|
|
|
|
|
|
|
mock_timeslot_list=(
|
|
|
|
{ 'phys_chan_config': 'val_phys_chan_config_0' },
|
|
|
|
{ 'phys_chan_config': 'val_phys_chan_config_1' },
|
|
|
|
{ 'phys_chan_config': 'val_phys_chan_config_2' },
|
|
|
|
{ 'phys_chan_config': 'val_phys_chan_config_3' },
|
|
|
|
)
|
|
|
|
|
|
|
|
mock_bts = {
|
2017-04-27 17:48:09 +00:00
|
|
|
'osmobsc_bts_type': 'val_type',
|
2017-03-28 10:16:58 +00:00
|
|
|
'band': 'val_band',
|
|
|
|
'location_area_code': 'val_bts.location_area_code',
|
2017-11-07 10:13:20 +00:00
|
|
|
'cell_identity': 'val_bts.cell_identity',
|
2017-03-28 10:16:58 +00:00
|
|
|
'base_station_id_code': 'val_bts.base_station_id_code',
|
2017-03-28 12:30:28 +00:00
|
|
|
'ipa_unit_id': 'val_bts.unit_id',
|
2017-03-28 10:16:58 +00:00
|
|
|
'stream_id': 'val_bts.stream_id',
|
2017-11-23 10:01:24 +00:00
|
|
|
'sgsn': (dict(ip_address=dict(addr='val_bts.sgsn_ip_addr'))),
|
2017-03-28 10:16:58 +00:00
|
|
|
'trx_list': (
|
|
|
|
dict(arfcn='val_trx_arfcn_trx0',
|
2017-09-14 11:52:28 +00:00
|
|
|
nominal_power='val_trx_nominal_power_trx0',
|
2017-03-28 10:16:58 +00:00
|
|
|
max_power_red='val_trx_max_power_red_trx0',
|
|
|
|
timeslot_list=mock_timeslot_list),
|
|
|
|
dict(arfcn='val_trx_arfcn_trx1',
|
2017-09-14 11:52:28 +00:00
|
|
|
nominal_power='val_trx_nominal_power_trx1',
|
2017-03-28 10:16:58 +00:00
|
|
|
max_power_red='val_trx_max_power_red_trx1',
|
|
|
|
timeslot_list=mock_timeslot_list),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-05-30 13:33:57 +00:00
|
|
|
mock_esme = {
|
|
|
|
'system_id': 'val_system_id',
|
|
|
|
'password': 'val_password'
|
|
|
|
}
|
|
|
|
|
2017-03-28 10:16:58 +00:00
|
|
|
def clone_mod(d, val_ext):
|
|
|
|
c = dict(d)
|
|
|
|
for name in c.keys():
|
|
|
|
if isinstance(c[name], str):
|
|
|
|
c[name] = c[name] + val_ext
|
|
|
|
elif isinstance(c[name], dict):
|
|
|
|
c[name] = clone_mod(c[name], val_ext)
|
|
|
|
return c
|
|
|
|
|
|
|
|
mock_bts0 = clone_mod(mock_bts, '_bts0')
|
|
|
|
mock_bts1 = clone_mod(mock_bts, '_bts1')
|
|
|
|
|
2017-05-30 13:33:57 +00:00
|
|
|
mock_esme0 = clone_mod(mock_esme, '_esme0')
|
|
|
|
mock_esme1 = clone_mod(mock_esme, '_esme1')
|
|
|
|
mock_esme1['password'] = ''
|
|
|
|
|
2017-03-28 12:30:28 +00:00
|
|
|
vals = dict(nitb=dict(
|
|
|
|
net=dict(
|
|
|
|
mcc='val_mcc',
|
|
|
|
mnc='val_mnc',
|
|
|
|
short_name='val_short_name',
|
|
|
|
long_name='val_long_name',
|
|
|
|
auth_policy='val_auth_policy',
|
|
|
|
encryption='val_encryption',
|
|
|
|
bts_list=(mock_bts0, mock_bts1)
|
|
|
|
),
|
2017-05-22 18:04:05 +00:00
|
|
|
ip_address=dict(addr='val_ip_address'),
|
|
|
|
),
|
2017-05-30 13:33:57 +00:00
|
|
|
smsc=dict(
|
|
|
|
policy='val_smsc_policy',
|
|
|
|
esme_list=(mock_esme0, mock_esme1)
|
|
|
|
),
|
2017-03-28 12:30:28 +00:00
|
|
|
)
|
2017-03-28 10:16:58 +00:00
|
|
|
|
|
|
|
print(template.render('osmo-nitb.cfg', vals))
|
|
|
|
|
|
|
|
print('- Testing: expect to fail on invalid templates dir')
|
|
|
|
try:
|
|
|
|
template.set_templates_dir('non-existing dir')
|
|
|
|
sys.stderr.write('Error: setting non-existing templates dir should raise RuntimeError\n')
|
|
|
|
assert(False)
|
|
|
|
except RuntimeError:
|
|
|
|
# not logging exception to omit non-constant path name from expected output
|
|
|
|
print('sucess: setting non-existing templates dir raised RuntimeError\n')
|
|
|
|
pass
|
|
|
|
|
|
|
|
# vim: expandtab tabstop=4 shiftwidth=4
|