示例#1
0
    def test_stun_server(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk STUN Server?')

        com = Commands.AstCommand('stun show status')
        rez = com.execute(0)
        lines = rez.split('\n')
        stunLine = lines.pop()
        while stunLine is "":
            stunLine = lines.pop()
        stun = stunLine.split(' ')[0].strip()
        self.assertEqual(stun, self.configs['asterisk']['stun'])
示例#2
0
    def test_db_entries(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Database Entries?')

        com = Commands.AstCommand('database show')
        rez = com.execute(0)
        lines = rez.split('\n')
        objFound = lines.pop()
        while objFound is "":
            objFound = lines.pop()
        numEntries = int(objFound.split(' ')[0].strip())
        self.assertEqual(numEntries,
                         self.configs['asterisk']['num_db_entries'])
示例#3
0
    def test_pjsip_endpoints(self):
        # alert the user of the current test
        print('\nTesting ---> PJSIP Endpoints Loaded?')

        com = Commands.AstCommand('pjsip show endpoints')
        rez = com.execute(0)
        lines = rez.split('\n')
        objFound = lines.pop()
        while objFound is "":
            objFound = lines.pop()
        numEndpoints = int(objFound.split(':')[1].strip())
        self.assertEqual(numEndpoints,
                         self.configs['asterisk']['num_endpoints'])
示例#4
0
    def test_loaded_modules(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Modules Loaded?')

        com = Commands.AstCommand('module show')
        rez = com.execute(0)
        status = True
        for module in self.configs['asterisk']['modules']:
            index = rez.find(module['name']) + 1  # returns -1 if not found
            if not index:
                print('{} was not loaded'.format(module['name']))
            status = status and index
        self.assertTrue(status)
示例#5
0
    def test_loaded_codecs(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Loaded Codecs?')

        com = Commands.AstCommand('core show codecs')
        rez = com.execute(0)
        status = True
        for codec in self.configs['asterisk']['codecs']:
            index = rez.find(codec["name"]) + 1  # returns -1 if not found
            if not index:
                print('{} was not loaded'.format(codec['name']))
            status = status and index
        self.assertTrue(status)
示例#6
0
    def test_ast_version(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Version Up-To-Date?')

        com = Commands.AstCommand('core show version')
        rez = com.execute(0)
        lines = rez.split('\n')
        line = lines.pop()
        while line is "":
            line = lines.pop()
        elems = line.split(' ')
        version = ""
        if elems[0] == 'Asterisk':
            version = elems[1]
        self.assertEqual(version, self.configs['asterisk']['version'])
示例#7
0
    def test_cdr_db(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Connected to CDR DB?')

        com = Commands.AstCommand('cdr show status')
        rez = com.execute(0)
        lines = rez.split('\n')
        status = ''
        for line in lines:
            words = line.split(':')
            for i, word in enumerate(words):
                clean = word.strip()
                if clean == 'Logging':
                    status = words[i + 1].strip()
        self.assertEqual(status, "Enabled")
示例#8
0
    def test_queues(self):
        # alert the user of the current test
        print('\nTesting ---> Asterisk Queue Number Non-Zero?')

        com = Commands.AstCommand('queue show')
        rez = com.execute(0)
        # sometimes the queue show returns 'No such command' so loop to get proper resp
        while rez.split(' ')[0].strip() == 'No':
            rez = com.execute(0)
        lines = rez.split('\n')
        queues = []
        for line in lines:
            position = line.find('Queue')
            if position > 0:
                queue = line.split(' ')[0].strip()
                queues.append(queue)
        self.assertEqual(len(queues), self.configs['asterisk']['num_queues'])