summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-09-25 23:23:57 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-09-28 18:52:57 +0200
commitf88c914efd4ef75bd861a669c943cfb82a8be789 (patch)
tree69b047c4242b373b4cf8c08a47267700ffbf1ca5
parentf95ce04cbda6caeedfc4d3d006313afff767f1af (diff)
add CTRL tests for enable-/disable-/status-ps
-rw-r--r--tests/ctrl_test_runner.py42
-rw-r--r--tests/test_subscriber.sql13
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index d453197..7c14f50 100644
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -163,6 +163,46 @@ class TestCtrlBase(unittest.TestCase):
return responses
+class TestCtrlHLR(TestCtrlBase):
+
+ HLR_DB = 'hlr_ctrl_test.db'
+ HLR_SQL = '%s/sql/hlr.sql' % confpath
+ HLR_TEST_SQL = '%s/tests/test_subscriber.sql' % confpath
+
+ def setUp(self):
+ print('\n')
+ print(os.getcwd())
+ assert subprocess.call('sqlite3 %s < %s' % (self.HLR_DB, self.HLR_SQL), shell=True) == 0
+ assert subprocess.call('sqlite3 %s < %s' % (self.HLR_DB, self.HLR_TEST_SQL), shell=True) == 0
+ super(TestCtrlHLR, self).setUp()
+
+ def tearDown(self):
+ super(TestCtrlHLR, self).tearDown()
+ os.unlink("hlr_ctrl_test.db")
+
+ def ctrl_command(self):
+ return ["./src/osmo-hlr", "-c", "doc/examples/osmo-hlr.cfg", '-l', 'hlr_ctrl_test.db']
+
+ def ctrl_app(self):
+ return (4259, "./src/osmo-hlr", "OsmoHLR", "hlr")
+
+ def testCtrlErrs(self):
+ r = self.do_get('invalid')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Command not found')
+
+ def testEnableDisablePs(self):
+ self.assert_set('enable-ps', '901990000000001', 'OK')
+ self.assert_set('status-ps', '901990000000001', '1')
+ self.assert_set('enable-ps', '901990000000001', 'OK')
+ self.assert_set('status-ps', '901990000000001', '1')
+ self.assert_set('disable-ps', '901990000000001', 'OK')
+ self.assert_set('status-ps', '901990000000001', '0')
+ self.assert_set('disable-ps', '901990000000001', 'OK')
+ self.assert_set('status-ps', '901990000000001', '0')
+ self.assert_set('enable-ps', '901990000000001', 'OK')
+ self.assert_set('status-ps', '901990000000001', '1')
+
if __name__ == '__main__':
import argparse
import sys
@@ -193,6 +233,8 @@ if __name__ == '__main__':
os.chdir(workdir)
print "Running tests for specific control commands"
suite = unittest.TestSuite()
+ test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlHLR)
+ suite.addTest(test)
res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
sys.exit(len(res.errors) + len(res.failures))
diff --git a/tests/test_subscriber.sql b/tests/test_subscriber.sql
new file mode 100644
index 0000000..0767d48
--- /dev/null
+++ b/tests/test_subscriber.sql
@@ -0,0 +1,13 @@
+
+-- 2G only subscriber
+INSERT INTO subscriber (id, imsi) VALUES (1, '901990000000001');
+INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki) VALUES (1, 1, '000102030405060708090a0b0c0d0e0f');
+
+-- 3G only subscriber
+INSERT INTO subscriber (id, imsi) VALUES (2, '901990000000002');
+INSERT INTO auc_3g (subscriber_id, algo_id_3g, k, opc, sqn) VALUES (2, 5, '000102030405060708090a0b0c0d0e0f', '101112131415161718191a1b1c1d1e1f', 0);
+
+-- 2G + 3G subscriber
+INSERT INTO subscriber (id, imsi) VALUES (3, '901990000000003');
+INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki) VALUES (3, 1, '000102030405060708090a0b0c0d0e0f');
+INSERT INTO auc_3g (subscriber_id, algo_id_3g, k, opc, sqn) VALUES (3, 5, '000102030405060708090a0b0c0d0e0f', '101112131415161718191a1b1c1d1e1f', 0);