#!/usr/bin/env python
'''
Copyright (C) 2010, Digium, Inc.
Russell Bryant <russell@digium.com>

This program is free software, distributed under the terms of
the GNU General Public License Version 2.
'''

import sys
from twisted.internet import reactor
import logging
import logging.config

sys.path.append("lib/python")
from asterisk.asterisk import Asterisk
from asterisk.test_case import TestCase
LOGGER = logging.getLogger(__name__)

class AMILoginTest(TestCase):
    def __init__(self):
        TestCase.__init__(self)
        self.create_asterisk()

    def ami_logoff(self, ami):
        self.passed = True
        self.stop_reactor()

    def ami_connect(self, ami):
        self.ami[0].logoff().addCallbacks(self.ami_logoff, self.ami_login_error)

    def run(self):
        TestCase.run(self)
        self.create_ami_factory()

def main():
    test = AMILoginTest()
    test.start_asterisk()
    reactor.run()
    test.stop_asterisk()
    if test.passed:
        return 0
    return 1


if __name__ == "__main__":
    sys.exit(main() or 0)


# vim:sw=4:ts=4:expandtab:textwidth=79
