Esempio n. 1
0
 def send_sms_with_e_scape(self, send_sms):
     try:
         logger = self.get_logger(pk=send_sms.pk)
         e_scape = E_Scape(settings.E_SCAPE_API_ID)
         [result] = e_scape.send_sms(
             smsc = settings.E_SCAPE_SMSC,
             sender = send_sms.from_msisdn,
             recipients = [send_sms.to_msisdn],
             text = send_sms.message
         )
         send_sms.save()
         return result
     except Exception, e:
         logger.debug('Retrying...')
         self.retry(args=[send_sms.pk], kwargs={})
Esempio n. 2
0
 def test_send_sms_response(self):
     """
     We get the following back from E-scape when we send them an SMS, make
     sure we can parse it correctly"""
     
     html = """
     <table class="widefat" border="0">
         <thead>
             <tr>
                 <th>from</th>
                 <th>to</th>
                 <th>smsc</th>
                 <th>status</th>
                 <th>text</th>
             </tr>
         </thead>
         <tbody>
             <tr>
                 <td>+35566</td>
                 <td>+44778962937</td>
                 <td>ESC-P1Celtel</td>
                 <td>0: Accepted for delivery</td>
                 <td> http://www.mobi-fee.com/link/g.lnk?ID=135</td>
             </tr>
         </tbody>
         <tfoot>
             <tr>
                 <th>from</th>
                 <th>to</th>
                 <th>smsc</th>
                 <th>status</th>
                 <th>text</th>
             </tr>
         </tfoot>
     </table>
     """
     e = E_Scape('api_id')
     [response] = e.parse_response(html)
     self.assertEquals(response.sender, '+35566')
     self.assertEquals(response.recipient, '+44778962937')
     self.assertEquals(response.smsc, 'ESC-P1Celtel')
     self.assertEquals(response.status, ['0', 'Accepted for delivery'])
     self.assertEquals(response.text, ' http://www.mobi-fee.com/link/g.lnk?ID=135')