Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
Archivo: tests.py Proyecto: 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")
Ejemplo n.º 3
0
 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")
Ejemplo n.º 4
0
 def setUp(self):
     do_setup()
     service_setup()
     
     mellon_setup()
     set_up_privileges()
     
     slashroot_set_up()
     
     self.admin = User.objects.create(is_superuser=True, username="******", password="******", first_name="Youhan")
     self.admin.set_password('admin')
     self.admin.save()
Ejemplo n.º 5
0
 def setUp(self):
     do_set_up()
     service_config.set_up()
     
     mellon_set_up()
     set_up_privileges()
     
     slashroot_set_up()
     
     #Create a known number for people to call.
     operator = User.objects.create(username="******", first_name="Operator")
     UserProfile.objects.create(user=operator, contact_info=ContactInfo.objects.create())
     self.known_number = PhoneNumber.objects.create(owner=operator.userprofile.contact_info, number="+11231231234")
     
     
     #Create a member and login.
     rusty = User.objects.create(is_superuser=True, username="******", first_name="Rusty", last_name="Spike")
     UserProfile.objects.create(user=rusty, contact_info=ContactInfo.objects.create())
     member_role = FixedObject.objects.get(name="RoleInGroup__slashroot_holder").object
     UserInGroup.objects.create(role=member_role, user=rusty)
             
     rusty.set_password('password')
     rusty.save()
     
     self.client.login(username="******", password="******")
      
     PhoneNumber.objects.create(owner=rusty.userprofile.contact_info, number="+18456797712")
     self.call_from_member = create_phone_calls(1, from_user=rusty, to_number=self.known_number)[0]
     
     #Create a service / tech client.        
     martha = User.objects.create(username="******", first_name="Martha")
     martha.set_password('password')
     martha.save()
     
     response = self.client.post('/service/check_in/', {'customer':'auth.user_%s___%s' % (martha.id, martha.username), 'projected':'12/21/2012'}, follow=True)
     service = Service.objects.all()[0]        
     UserProfile.objects.create(user=service.recipient.user, contact_info=ContactInfo.objects.create())       
     PhoneNumber.objects.create(owner=service.recipient.user.userprofile.contact_info, number="+18456797779")
     self.call_from_client = create_phone_calls(1, from_user=service.recipient.user, to_number=self.known_number)[0]
     
     
     #Create an "other known caller."
     somebody_else = User.objects.create(username="******", first_name="somebody")
     UserProfile.objects.create(user=somebody_else, contact_info=ContactInfo.objects.create())
     PhoneNumber.objects.create(owner=somebody_else.userprofile.contact_info, number="+18456797723")
     self.call_from_other_known = create_phone_calls(1, from_user=somebody_else, to_number=self.known_number)[0]
     
     
     #Create an unknown caller.
     unknown_number = PhoneNumber.objects.create(number="+18456797756")
     self.call_from_unknown = create_phone_calls(1, from_number=unknown_number, to_number=self.known_number)[0]
Ejemplo n.º 6
0
Archivo: tests.py Proyecto: jMyles/WHAT
    def setUp(self):
        do_setup()
        service_setup()

        mellon_setup()
        set_up_privileges()

        slashroot_set_up()

        self.admin = User.objects.create(is_superuser=True,
                                         username="******",
                                         password="******",
                                         first_name="Youhan")
        self.admin.set_password('admin')
        self.admin.save()
Ejemplo n.º 7
0
Archivo: tests.py Proyecto: 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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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()
Ejemplo n.º 10
0
Archivo: tests.py Proyecto: 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
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
    def setUp(self):
        do_set_up()
        service_config.set_up()

        mellon_set_up()
        set_up_privileges()

        slashroot_set_up()

        #Create a known number for people to call.
        operator = User.objects.create(username="******",
                                       first_name="Operator")
        UserProfile.objects.create(user=operator,
                                   contact_info=ContactInfo.objects.create())
        self.known_number = PhoneNumber.objects.create(
            owner=operator.userprofile.contact_info, number="+11231231234")

        #Create a member and login.
        rusty = User.objects.create(is_superuser=True,
                                    username="******",
                                    first_name="Rusty",
                                    last_name="Spike")
        UserProfile.objects.create(user=rusty,
                                   contact_info=ContactInfo.objects.create())
        member_role = FixedObject.objects.get(
            name="RoleInGroup__slashroot_holder").object
        UserInGroup.objects.create(role=member_role, user=rusty)

        rusty.set_password('password')
        rusty.save()

        self.client.login(username="******", password="******")

        PhoneNumber.objects.create(owner=rusty.userprofile.contact_info,
                                   number="+18456797712")
        self.call_from_member = create_phone_calls(
            1, from_user=rusty, to_number=self.known_number)[0]

        #Create a service / tech client.
        martha = User.objects.create(username="******", first_name="Martha")
        martha.set_password('password')
        martha.save()

        response = self.client.post(
            '/service/check_in/', {
                'customer': 'auth.user_%s___%s' % (martha.id, martha.username),
                'projected': '12/21/2012'
            },
            follow=True)
        service = Service.objects.all()[0]
        UserProfile.objects.create(user=service.recipient.user,
                                   contact_info=ContactInfo.objects.create())
        PhoneNumber.objects.create(
            owner=service.recipient.user.userprofile.contact_info,
            number="+18456797779")
        self.call_from_client = create_phone_calls(
            1, from_user=service.recipient.user,
            to_number=self.known_number)[0]

        #Create an "other known caller."
        somebody_else = User.objects.create(username="******",
                                            first_name="somebody")
        UserProfile.objects.create(user=somebody_else,
                                   contact_info=ContactInfo.objects.create())
        PhoneNumber.objects.create(
            owner=somebody_else.userprofile.contact_info,
            number="+18456797723")
        self.call_from_other_known = create_phone_calls(
            1, from_user=somebody_else, to_number=self.known_number)[0]

        #Create an unknown caller.
        unknown_number = PhoneNumber.objects.create(number="+18456797756")
        self.call_from_unknown = create_phone_calls(
            1, from_number=unknown_number, to_number=self.known_number)[0]