コード例 #1
0
    def test_export_conversation_endpoints(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_outbound("outbound",
                                            conv=conv,
                                            to_addr='from-1')
        msg.set_routing_endpoint('foo')
        self.msg_helper.store_outbound(conv, msg)

        msg = self.msg_helper.make_outbound("inbound",
                                            conv=conv,
                                            from_addr='from-1')
        msg.set_routing_endpoint('bar')
        self.msg_helper.store_inbound(conv, msg)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                         'messages-export.csv')
        reader = csv.DictReader(fp)
        [row1, row2] = list(reader)
        self.assertEqual(row1['direction'], 'inbound')
        self.assertEqual(row1['endpoint'], 'bar')
        self.assertEqual(row2['direction'], 'outbound')
        self.assertEqual(row2['endpoint'], 'foo')
コード例 #2
0
    def test_export_conversation_message_session_events(self):
        conv = self.create_conversation(reply_count=0)
        msg = self.msg_helper.make_stored_inbound(
            conv,
            "inbound",
            from_addr='from-1',
            session_event=TransportUserMessage.SESSION_NEW)

        reply = self.msg_helper.make_reply(
            msg, "reply", session_event=TransportUserMessage.SESSION_CLOSE)

        self.msg_helper.store_outbound(conv, reply)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                         'messages-export.csv')
        reader = csv.DictReader(fp)
        events = [row['session_event'] for row in reader]
        self.assertEqual(
            set(events),
            set([
                TransportUserMessage.SESSION_NEW,
                TransportUserMessage.SESSION_CLOSE
            ]))
コード例 #3
0
 def test_export_conversation_message_directions(self):
     conv = self.create_conversation()
     export_conversation_messages_unsorted(conv.user_account.key, conv.key)
     [email] = mail.outbox
     fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                      'messages-export.csv')
     reader = csv.DictReader(fp)
     directions = [row['direction'] for row in reader]
     self.assertEqual(set(directions), set(['inbound', 'outbound']))
コード例 #4
0
ファイル: tests.py プロジェクト: TouK/vumi-go
 def test_export_conversation_message_directions(self):
     conv = self.create_conversation()
     export_conversation_messages_unsorted(conv.user_account.key, conv.key)
     [email] = mail.outbox
     fp = self.get_zipfile_attachment(
         email, 'messages-export.zip', 'messages-export.csv')
     reader = csv.DictReader(fp)
     directions = [row['direction'] for row in reader]
     self.assertEqual(
         set(directions),
         set(['inbound', 'outbound']))
コード例 #5
0
ファイル: tests.py プロジェクト: TouK/vumi-go
    def test_export_conversation_delivery_status(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_stored_outbound(
            conv, "outbound", to_addr='from-1')
        self.msg_helper.make_stored_delivery_report(msg=msg, conv=conv)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(
            email, 'messages-export.zip', 'messages-export.csv')
        reader = csv.DictReader(fp)
        delivery_statuses = [row['delivery_status'] for row in reader]
        self.assertEqual(set(delivery_statuses), set(['delivered']))
コード例 #6
0
ファイル: tests.py プロジェクト: TouK/vumi-go
    def test_export_conversation_ack(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_stored_outbound(
            conv, "outbound", to_addr='from-1')
        self.msg_helper.make_stored_ack(msg=msg, conv=conv)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(
            email, 'messages-export.zip', 'messages-export.csv')
        reader = csv.DictReader(fp)
        [row] = list(reader)
        self.assertEqual(row['network_handover_status'], 'ack')
コード例 #7
0
 def test_export_conversation_messages_unsorted(self):
     conv = self.create_conversation()
     export_conversation_messages_unsorted(conv.user_account.key, conv.key)
     [email] = mail.outbox
     self.assertEqual(email.recipients(),
                      [self.user_helper.get_django_user().email])
     self.assertTrue(conv.name in email.subject)
     self.assertTrue(conv.name in email.body)
     fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                      'messages-export.csv')
     reader = csv.DictReader(fp)
     message_ids = [row['message_id'] for row in reader]
     self.assertEqual(set(message_ids),
                      set(conv.inbound_keys() + conv.outbound_keys()))
コード例 #8
0
ファイル: tests.py プロジェクト: TouK/vumi-go
 def test_export_conversation_messages_unsorted(self):
     conv = self.create_conversation()
     export_conversation_messages_unsorted(conv.user_account.key, conv.key)
     [email] = mail.outbox
     self.assertEqual(
         email.recipients(), [self.user_helper.get_django_user().email])
     self.assertTrue(conv.name in email.subject)
     self.assertTrue(conv.name in email.body)
     fp = self.get_zipfile_attachment(
         email, 'messages-export.zip', 'messages-export.csv')
     reader = csv.DictReader(fp)
     message_ids = [row['message_id'] for row in reader]
     self.assertEqual(
         set(message_ids),
         set(conv.inbound_keys() + conv.outbound_keys()))
コード例 #9
0
    def test_export_conversation_ack(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_stored_outbound(conv,
                                                   "outbound",
                                                   to_addr='from-1')
        self.msg_helper.make_stored_ack(msg=msg, conv=conv)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                         'messages-export.csv')
        reader = csv.DictReader(fp)
        [row] = list(reader)
        self.assertEqual(row['network_handover_status'], 'ack')
コード例 #10
0
    def test_export_conversation_delivery_status(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_stored_outbound(conv,
                                                   "outbound",
                                                   to_addr='from-1')
        self.msg_helper.make_stored_delivery_report(msg=msg, conv=conv)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                         'messages-export.csv')
        reader = csv.DictReader(fp)
        delivery_statuses = [row['delivery_status'] for row in reader]
        self.assertEqual(set(delivery_statuses), set(['delivered']))
コード例 #11
0
ファイル: tests.py プロジェクト: TouK/vumi-go
    def test_export_conversation_message_transport_types(self):
        conv = self.create_conversation(reply_count=0)
        # SMS message
        self.msg_helper.make_stored_inbound(
            conv, "inbound", from_addr='from-1', transport_type='sms')
        # USSD message
        self.msg_helper.make_stored_inbound(
            conv, "inbound", from_addr='from-1', transport_type='ussd')

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(
            email, 'messages-export.zip', 'messages-export.csv')
        reader = csv.DictReader(fp)
        events = [row['transport_type'] for row in reader]
        self.assertEqual(
            set(events),
            set(['sms', 'ussd']))
コード例 #12
0
    def test_export_conversation_message_transport_types(self):
        conv = self.create_conversation(reply_count=0)
        # SMS message
        self.msg_helper.make_stored_inbound(conv,
                                            "inbound",
                                            from_addr='from-1',
                                            transport_type='sms')
        # USSD message
        self.msg_helper.make_stored_inbound(conv,
                                            "inbound",
                                            from_addr='from-1',
                                            transport_type='ussd')

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(email, 'messages-export.zip',
                                         'messages-export.csv')
        reader = csv.DictReader(fp)
        events = [row['transport_type'] for row in reader]
        self.assertEqual(set(events), set(['sms', 'ussd']))
コード例 #13
0
ファイル: tests.py プロジェクト: TouK/vumi-go
    def test_export_conversation_message_session_events(self):
        conv = self.create_conversation(reply_count=0)
        msg = self.msg_helper.make_stored_inbound(
            conv, "inbound", from_addr='from-1',
            session_event=TransportUserMessage.SESSION_NEW)

        reply = self.msg_helper.make_reply(
            msg, "reply", session_event=TransportUserMessage.SESSION_CLOSE)

        self.msg_helper.store_outbound(conv, reply)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(
            email, 'messages-export.zip', 'messages-export.csv')
        reader = csv.DictReader(fp)
        events = [row['session_event'] for row in reader]
        self.assertEqual(
            set(events),
            set([TransportUserMessage.SESSION_NEW,
                 TransportUserMessage.SESSION_CLOSE]))
コード例 #14
0
ファイル: tests.py プロジェクト: TouK/vumi-go
    def test_export_conversation_endpoints(self):
        conv = self.create_conversation(reply_count=0)

        msg = self.msg_helper.make_outbound(
            "outbound", conv=conv, to_addr='from-1')
        msg.set_routing_endpoint('foo')
        self.msg_helper.store_outbound(conv, msg)

        msg = self.msg_helper.make_outbound(
            "inbound", conv=conv, from_addr='from-1')
        msg.set_routing_endpoint('bar')
        self.msg_helper.store_inbound(conv, msg)

        export_conversation_messages_unsorted(conv.user_account.key, conv.key)
        [email] = mail.outbox
        fp = self.get_zipfile_attachment(
            email, 'messages-export.zip', 'messages-export.csv')
        reader = csv.DictReader(fp)
        [row1, row2] = list(reader)
        self.assertEqual(row1['direction'], 'inbound')
        self.assertEqual(row1['endpoint'], 'bar')
        self.assertEqual(row2['direction'], 'outbound')
        self.assertEqual(row2['endpoint'], 'foo')