예제 #1
0
 def test_multi_calls(self):
     params = dict(self.example_params)
     campaign = server.get_campaign('default')
     # call both Pelosi and Boxer
     params['repIds'].append(id_boxer)
     # connect
     tree = self.post_tree('connection', **params)
     
     for i, repId in enumerate(params['repIds']):
         url, qparams = self.parse_url(tree.find('Redirect').text)
         assert(url.path == '/make_single_call')
         assert(qparams['call_index'] == str(i))
         assert(qparams['repIds'] == params['repIds'])
     
         # if we follow that redirect to make a call
         tree = self.post_tree(url.geturl())
         rep_phone = self.legislators.ix[repId, 'phone']
         assert(tree[1].tag == 'Dial' and tree[1].text == rep_phone)
         url, qparams = self.parse_url(dict(tree[1].items())['action'])
         # dial action should go to call_complete 
         assert(url.path == '/call_complete')
         assert(qparams['call_index'] == str(i))
         assert(qparams['repIds'] == params['repIds'])
     
         # assume call success
         tree = self.post_tree(url.path, **dict(
             DialCallStatus='Success', DialCallDuration=60, **qparams))
             
         call = models.Call.query.order_by(models.Call.timestamp).all()[-1]
         assert(call.member_id == repId)
         
     else:
         assert(len(tree) == 1 and tree[0].tag == 'Say' \
             and tree[0].text == campaign['msg_final_thanks'])
         assert(models.Call.query.count() == len(params['repIds']))
예제 #2
0
 def test_preset_reps(self):
     params = dict(campaignId='call-Ted-Cruz', userPhone='123-456-7890')
     campaign = server.get_campaign(params['campaignId'])
     req = self.app.post(url_for('connection', **params))
     tree = lxml.etree.fromstring(req.data)
     # main intro msg
     assert (campaign['msg_intro'] == tree[0].text)
     # and then redirect to make call based on campaign's repIds
     url, qparams = self.parse_url(tree.find('Redirect').text)
     assert (url.path == '/make_single_call')
     assert ([qparams['repIds']] == campaign['repIds'])
예제 #3
0
 def test_preset_reps(self):
     params = dict(campaignId='call-Ted-Cruz', userPhone='123-456-7890')
     campaign = server.get_campaign(params['campaignId'])
     req = self.app.post(url_for('connection', **params))
     tree = lxml.etree.fromstring(req.data)
     # main intro msg
     assert(campaign['msg_intro'] == tree[0].text)
     # and then redirect to make call based on campaign's repIds
     url, qparams = self.parse_url(tree.find('Redirect').text)
     assert(url.path == '/make_single_call')
     assert([qparams['repIds']] == campaign['repIds'])
예제 #4
0
    def test_multi_calls(self):
        params = dict(self.example_params)
        campaign = server.get_campaign('default')
        # call both Pelosi and Boxer
        params['repIds'].append(id_boxer)
        # connect
        tree = self.post_tree('connection', **params)

        for i, repId in enumerate(params['repIds']):
            url, qparams = self.parse_url(tree.find('Redirect').text)
            assert (url.path == '/make_single_call')
            assert (qparams['call_index'] == str(i))
            assert (qparams['repIds'] == params['repIds'])

            # if we follow that redirect to make a call
            tree = self.post_tree(url.geturl())
            rep_phone = self.legislators.ix[repId, 'phone']
            assert (tree[1].tag == 'Dial' and tree[1].text == rep_phone)
            url, qparams = self.parse_url(dict(tree[1].items())['action'])
            # dial action should go to call_complete
            assert (url.path == '/call_complete')
            assert (qparams['call_index'] == str(i))
            assert (qparams['repIds'] == params['repIds'])

            # assume call success
            tree = self.post_tree(
                url.path,
                **dict(DialCallStatus='Success',
                       DialCallDuration=60,
                       **qparams))

            call = models.Call.query.order_by(models.Call.timestamp).all()[-1]
            assert (call.member_id == repId)

        else:
            assert(len(tree) == 1 and tree[0].tag == 'Say' \
                and tree[0].text == campaign['msg_final_thanks'])
            assert (models.Call.query.count() == len(params['repIds']))