#!/usr/bin/env python
'''
Copyright (C) 2011, Digium, Inc.
Kinsey Moore <kmoore@digium.com>

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

import sys
import os

sys.path.append("lib/python")

from twisted.internet import reactor
from asterisk.sipp import SIPpTest
from asterisk.version import AsteriskVersion


WORKING_DIR = "SIP/SDP_offer_answer"
TEST_DIR = os.path.dirname(os.path.realpath(__file__))

SIPP_SCENARIOS = [
    {'scenario' : 'single_audio.xml',},
    {'scenario' : 'decline_incompat_audio.xml',},
    {'scenario' : 'single_video.xml',},
    {'scenario' : 'single_video_inverse.xml',},
    {'scenario' : 'decline_incompat_video.xml',},
    {'scenario' : 'single_text.xml',},
    {'scenario' : 'single_text_inverse.xml',},
    {'scenario' : 'decline_incompat_text.xml',},
    {'scenario' : 'single_image.xml',},
    {'scenario' : 'single_image_inverse.xml',},
    {'scenario' : 'decline_unsupported_image.xml',},
    {'scenario' : 'avt_streams.xml',},
    {'scenario' : 'multistream.xml',},
    {'scenario' : 'fax_sim.xml',},
    {'scenario' : 'decline_crypto.xml',},
    {'scenario' : 'orderstream.xml',},
]

# generate SIPP scenarios with appropriate port numbers and the config to go with it
def main():
    if AsteriskVersion() > AsteriskVersion("11"):
        SIPP_SCENARIOS.append({'scenario' : 'decline_multistream.xml'})
        SIPP_SCENARIOS.append({'scenario' : 'decline_unsupported_image_multi.xml'})
    else:
        SIPP_SCENARIOS.append({'scenario' : 'decline_unsupported_image_multi_1.8.xml'})
    test = SIPpTest(WORKING_DIR, TEST_DIR, SIPP_SCENARIOS)
    reactor.run()
    if not test.passed:
        return 1

    return 0


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


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