class TestDecoding(unittest.TestCase): def __init__(self, name, version=None): super(TestDecoding, self).__init__(name) self.version = version self.path = os.path.join(os.getcwd(), "traces", version) def setUp(self): self.ajam = Pyajam() self.ajam._query = fake_query(self.path, self._testMethodName.split('_')[1]) # we *force* asterisk version in ajam (note if we run *test_login*, will be replaced by real version) self.ajam._version_ = self.version def tearDown(self): self.ajam = None def test_login(self): self.assertTrue(self.ajam.login()) self.assertEqual(self.ajam.version(), self.version) self.assertEqual(self.ajam._sessionid_, '3ac1e27b') def test_sippeers(self): peers = self.ajam.sippeers() self.assertEqual(len(peers), 2) self.assertTrue(peers[0].get('objectname', 'none') in ['101', '102']) def test_iaxpeers(self): peers = self.ajam.iaxpeers() self.assertEqual(len(peers), 1) self.assertEqual(peers[0].get('objectname', 'none'), 'demo') def test_peers(self): peers = self.ajam.peers() self.assertEqual(len(peers), 3) self.assertEqual(len([x for x in peers if x['channeltype'] == 'SIP']), 2) self.assertEqual(len([x for x in peers if x['channeltype'] == 'IAX2']), 1) def test_sipregistry(self): regs = self.ajam.sipregistry() self.assertEqual(len(regs), 1) self.assertEqual(regs[0]['username'], 'myISP') def test_peer(self): peer = self.ajam.sippeer('101') self.assertTrue(isinstance(peer, dict)) self.assertEqual(peer.get('objectname', None), '101') self.assertEqual(peer.get('status', None), 'Unmonitored')
class TestDecoding(unittest.TestCase): def __init__(self, name, version=None): super(TestDecoding, self).__init__(name) self.version = version self.path = os.path.join(os.getcwd(), "traces", version) def setUp(self): self.ajam = Pyajam() self.ajam._query = fake_query(self.path, self._testMethodName.split('_')[1]) # we *force* asterisk version in ajam (note if we run *test_login*, will be replaced by real version) self.ajam._version_ = self.version def tearDown(self): self.ajam = None def test_login(self): self.assertTrue(self.ajam.login()) self.assertEqual(self.ajam.version(), self.version) self.assertEqual(self.ajam._sessionid_, '3ac1e27b') def test_sippeers(self): peers = self.ajam.sippeers() self.assertEqual(len(peers), 2) self.assertTrue(peers[0].get('objectname', 'none') in ['101','102']) def test_iaxpeers(self): peers = self.ajam.iaxpeers() self.assertEqual(len(peers), 1) self.assertEqual(peers[0].get('objectname','none'), 'demo') def test_peers(self): peers = self.ajam.peers() self.assertEqual(len(peers), 3) self.assertEqual(len([x for x in peers if x['channeltype'] == 'SIP']), 2) self.assertEqual(len([x for x in peers if x['channeltype'] == 'IAX2']), 1) def test_sipregistry(self): regs = self.ajam.sipregistry() self.assertEqual(len(regs), 1) self.assertEqual(regs[0]['username'], 'myISP') def test_peer(self): peer = self.ajam.sippeer('101') self.assertTrue(isinstance(peer, dict)) self.assertEqual(peer.get('objectname',None), '101') self.assertEqual(peer.get('status',None), 'Unmonitored')
def ajax_mesa(): import pprint from pyajam import Pyajam ajam = Pyajam(username='******', password='******') con = ajam.peers() dict_final={} ramal = db(Ramal_virtual).select(Ramal_virtual.ramal_virtual, Ramal_virtual.ramal_fisico) print ramal for dado in con: for rm in ramal: if rm.ramal_fisico == dado['objectname']: print dado['objectname'] dict_final[rm.ramal_virtual]=dado return response.json(dict_final)
def ajax_mesa(): import pprint from pyajam import Pyajam ajam = Pyajam(username='******', password='******') con = ajam.peers() dict_final = {} ramal = db(Ramal_virtual).select(Ramal_virtual.ramal_virtual, Ramal_virtual.ramal_fisico) print ramal for dado in con: for rm in ramal: if rm.ramal_fisico == dado['objectname']: print dado['objectname'] dict_final[rm.ramal_virtual] = dado return response.json(dict_final)