예제 #1
0
파일: tests.py 프로젝트: SlashRoot/WHAT
def prepare_testcase_for_answer_tests(testcase):
    '''
    Takes a test case and adds proper objects for it to conduct tests about responding to incoming calls.
    Returns the PhoneCall object that is created when the call is answered.
    '''
    do_config.set_up()
    mellon_config.set_up()
    do_config.set_up_privileges()
    
    #Providers
    set_up_providers(testcase)
    
    #The dial list
    testcase.diallist = DialList.objects.create(name="SlashRoot First Dial")
    
    #Twilio response to calls
    testcase.http_response_to_twilio_request = testcase.client.post("/comm/phone/", TYPICAL_TWILIO_REQUEST)
    testcase.twilio_response_object = testcase.http_response_to_twilio_request._container[0]
    
    #Tropo response to calls
    fake_initial_request = FakeRequest(TYPICAL_TROPO_REQUEST)
    testcase.http_response_to_tropo_request = answer(fake_initial_request)
    testcase.tropo_response_dict = json.loads(testcase.http_response_to_tropo_request.content)
    
    testcase.twilio_interpretation_of_conference_id = testcase.twilio_response_object.verbs[1].verbs[0].body
    
    tropo_join_conference_command = find_command_in_tropo_command_list(testcase.tropo_response_dict['tropo'], signal_on="joinConference")
    testcase.tropo_interpretation_of_conference_id = tropo_join_conference_command['on']['next'].split('/')[3] #Turn the list into a dict - we know there's only one conference verb.
    
    testcase.tropo_call_id = PhoneCall.objects.get(call_id = testcase.tropo_interpretation_of_conference_id).id #We need the actual ID of the phone call, and it's not clear from the dict.  This is basically a short cut. 
    testcase.twilio_call_id = PhoneCall.objects.get(call_id = testcase.twilio_interpretation_of_conference_id).id
    
    return testcase.twilio_interpretation_of_conference_id, testcase.tropo_interpretation_of_conference_id
예제 #2
0
파일: tests.py 프로젝트: SlashRoot/WHAT
 def setUp(self):
     do_config.set_up()
     admin = User.objects.create(is_superuser=True, username="******", password="******")
     admin.set_password('admin')
     admin.save()
     set_up_providers(self)
     slashroot_set_up()
예제 #3
0
파일: tests.py 프로젝트: jMyles/WHAT
    def setUp(self):
        do_config.set_up()
        mellon_config.set_up()
        do_config.set_up_privileges()

        self.tropo_provider = PhoneProvider.objects.create(name="Tropo")
        self.twilio_provider = PhoneProvider.objects.create(name="Twilio")

        self.diallist = DialList.objects.create(name="test_dial_list")
예제 #4
0
파일: tests.py 프로젝트: jMyles/WHAT
 def setUp(self):
     do_config.set_up()
     admin = User.objects.create(is_superuser=True,
                                 username="******",
                                 password="******")
     admin.set_password('admin')
     admin.save()
     set_up_providers(self)
     slashroot_set_up()
예제 #5
0
파일: tests.py 프로젝트: SlashRoot/WHAT
 def setUp(self):
     do_config.set_up()
     mellon_config.set_up()
     do_config.set_up_privileges()
     
     self.tropo_provider = PhoneProvider.objects.create(name="Tropo")
     self.twilio_provider = PhoneProvider.objects.create(name="Twilio")
     
     self.diallist = DialList.objects.create(name="test_dial_list")
예제 #6
0
파일: tests.py 프로젝트: jMyles/WHAT
def prepare_testcase_for_answer_tests(testcase):
    '''
    Takes a test case and adds proper objects for it to conduct tests about responding to incoming calls.
    Returns the PhoneCall object that is created when the call is answered.
    '''
    do_config.set_up()
    mellon_config.set_up()
    do_config.set_up_privileges()

    #Providers
    set_up_providers(testcase)

    #The dial list
    testcase.diallist = DialList.objects.create(name="SlashRoot First Dial")

    #Twilio response to calls
    testcase.http_response_to_twilio_request = testcase.client.post(
        "/comm/phone/", TYPICAL_TWILIO_REQUEST)
    testcase.twilio_response_object = testcase.http_response_to_twilio_request._container[
        0]

    #Tropo response to calls
    fake_initial_request = FakeRequest(TYPICAL_TROPO_REQUEST)
    testcase.http_response_to_tropo_request = answer(fake_initial_request)
    testcase.tropo_response_dict = json.loads(
        testcase.http_response_to_tropo_request.content)

    testcase.twilio_interpretation_of_conference_id = testcase.twilio_response_object.verbs[
        1].verbs[0].body

    tropo_join_conference_command = find_command_in_tropo_command_list(
        testcase.tropo_response_dict['tropo'], signal_on="joinConference")
    testcase.tropo_interpretation_of_conference_id = tropo_join_conference_command[
        'on']['next'].split(
            '/'
        )[3]  #Turn the list into a dict - we know there's only one conference verb.

    testcase.tropo_call_id = PhoneCall.objects.get(
        call_id=testcase.tropo_interpretation_of_conference_id
    ).id  #We need the actual ID of the phone call, and it's not clear from the dict.  This is basically a short cut.
    testcase.twilio_call_id = PhoneCall.objects.get(
        call_id=testcase.twilio_interpretation_of_conference_id).id

    return testcase.twilio_interpretation_of_conference_id, testcase.tropo_interpretation_of_conference_id
예제 #7
0
파일: tests.py 프로젝트: SlashRoot/WHAT
def create_phone_calls(number_of_phone_calls_to_create, from_user=None, to_user=None, from_number=None, to_number=None):
    do_config.set_up()
    mellon_config.set_up()
    do_config.set_up_privileges()
    phone_calls = []
    twilio = PhoneProvider.objects.get_or_create(name="Twilio")[0]
    
    if from_user and from_number:
        raise TypeError('Specify either from_user or from_number - not both.')
    
    if to_user and to_number:
        raise TypeError('Specify either to_user or to_number - not both.')
    
    #From
    
    if from_number:
        pass #We'll just use this.
    elif from_user:
        UserProfile.objects.get_or_create(user=from_user, defaults={'contact_info':ContactInfo.objects.create()})
        from_number = PhoneNumber.objects.get_or_create(owner=from_user.userprofile.contact_info, defaults=dict(number="+15551231234"))[0]        
    else:
        from_number = PhoneNumber.objects.get_or_create(type='mobile', number='+18455551234')[0]
    
    if to_number:
        pass #We'll just use this.
    elif to_user:
        UserProfile.objects.get_or_create(user=to_user, defaults={'contact_info':ContactInfo.objects.create()})
        to_number = PhoneNumber.objects.create(owner=to_user.userprofile.contact_info, number="+15551231234")        
    else:
        to_number = PhoneNumber.objects.get_or_create(type='mobile', number='+18455551234')[0]
    
    number_of_existing_calls = PhoneCall.objects.count()
    
    for x in range(number_of_existing_calls+1, number_of_existing_calls+number_of_phone_calls_to_create+1):
        phone_call = PhoneCall.objects.create(service=twilio, call_id=x, from_number=from_number, to_number=to_number)
        phone_calls.append(phone_call)
        
        if from_user:
            CommunicationInvolvement.objects.create(communication=phone_call, person=from_user, direction="from")
        if to_user:
            CommunicationInvolvement.objects.create(communication=phone_call, person=to_user, direction="to")
        
    return phone_calls
예제 #8
0
from what_apps.mellon import config as mellon_config
from what_apps.do import config as do_config
from what_apps.slashroot import config as slashroot_config
from what_apps.people import config as people_config
from what_apps.contact import config as contact_config
from what_apps.comm import config as comm_config

utility = ManagementUtility(['', 'syncdb', '--noinput'])
utility.execute()

utility = ManagementUtility(['', 'migrate'])
utility.execute()

mellon_config.set_up()
do_config.set_up_privileges()
do_config.set_up()

slashroot_config.set_up()

admin = User.objects.get_or_create(username="******", is_superuser=True)[0]
admin.set_password('admin')
admin.save()

rusty, rusty_profile = people_config.setup()
rusty_contact, rusty_home_number, rusty_work_number = contact_config.setup(
    userprofile=rusty_profile)

rusty_profile.contact_info = rusty_contact
rusty_profile.save()

comm_config.setup(rusty_home_number)
예제 #9
0
파일: tests.py 프로젝트: jMyles/WHAT
def create_phone_calls(number_of_phone_calls_to_create,
                       from_user=None,
                       to_user=None,
                       from_number=None,
                       to_number=None):
    do_config.set_up()
    mellon_config.set_up()
    do_config.set_up_privileges()
    phone_calls = []
    twilio = PhoneProvider.objects.get_or_create(name="Twilio")[0]

    if from_user and from_number:
        raise TypeError('Specify either from_user or from_number - not both.')

    if to_user and to_number:
        raise TypeError('Specify either to_user or to_number - not both.')

    #From

    if from_number:
        pass  #We'll just use this.
    elif from_user:
        UserProfile.objects.get_or_create(
            user=from_user,
            defaults={'contact_info': ContactInfo.objects.create()})
        from_number = PhoneNumber.objects.get_or_create(
            owner=from_user.userprofile.contact_info,
            defaults=dict(number="+15551231234"))[0]
    else:
        from_number = PhoneNumber.objects.get_or_create(
            type='mobile', number='+18455551234')[0]

    if to_number:
        pass  #We'll just use this.
    elif to_user:
        UserProfile.objects.get_or_create(
            user=to_user,
            defaults={'contact_info': ContactInfo.objects.create()})
        to_number = PhoneNumber.objects.create(
            owner=to_user.userprofile.contact_info, number="+15551231234")
    else:
        to_number = PhoneNumber.objects.get_or_create(type='mobile',
                                                      number='+18455551234')[0]

    number_of_existing_calls = PhoneCall.objects.count()

    for x in range(
            number_of_existing_calls + 1,
            number_of_existing_calls + number_of_phone_calls_to_create + 1):
        phone_call = PhoneCall.objects.create(service=twilio,
                                              call_id=x,
                                              from_number=from_number,
                                              to_number=to_number)
        phone_calls.append(phone_call)

        if from_user:
            CommunicationInvolvement.objects.create(communication=phone_call,
                                                    person=from_user,
                                                    direction="from")
        if to_user:
            CommunicationInvolvement.objects.create(communication=phone_call,
                                                    person=to_user,
                                                    direction="to")

    return phone_calls
예제 #10
0
파일: setup_db.py 프로젝트: SlashRoot/WHAT
from django.core.management import ManagementUtility
from what_apps.mellon import config as mellon_config
from what_apps.do import config as do_config
from what_apps.slashroot import config as slashroot_config
from what_apps.people import config as people_config
from what_apps.contact import config as contact_config
from what_apps.comm import config as comm_config

utility = ManagementUtility(['', 'syncdb', '--noinput'])
utility.execute()

utility = ManagementUtility(['', 'migrate'])
utility.execute()

mellon_config.set_up()
do_config.set_up_privileges()
do_config.set_up()

slashroot_config.set_up()

admin = User.objects.get_or_create(username="******", is_superuser=True)[0]
admin.set_password('admin')
admin.save()

rusty, rusty_profile = people_config.setup()
rusty_contact, rusty_home_number, rusty_work_number = contact_config.setup(userprofile=rusty_profile)

rusty_profile.contact_info = rusty_contact
rusty_profile.save()

comm_config.setup(rusty_home_number)