Example #1
0
    def setUp(self):
        self.user = User.objects.get(username='******')

        self.sms_dialer_setting = UserProfile.objects.get(user=self.user).dialersetting
        self.sms_dialer_setting.save()

        self.smscampaign = SMSCampaign(
            name="SMS Campaign",
            user=self.user,
            sms_gateway_id=1,
            status=2
        )
        self.smscampaign.save()
        self.assertEqual(self.smscampaign.__unicode__(), u'SMS Campaign')

        self.sms = SMSMessage(
            message_id=1,
            sms_campaign_id=1,
            sms_gateway_id=1,
            sender=self.user,
            content_type_id=1,
            object_id=1,
            uuid=str(uuid1()),
        )
        self.sms.save()

        # Subscriber model
        self.smssubscriber = SMSCampaignSubscriber(
            message_id=1,
            sms_campaign=self.smscampaign,
            contact_id=1,
            count_attempt=0,
            duplicate_contact=1,
            status=1
        )
        self.smssubscriber.save()
        self.assertTrue(self.smssubscriber.__unicode__())

        # Test mgt command
        call_command("create_sms", "1|10")
Example #2
0
class SMSCampaignModel(TestCase):
    """Test SMSCampaign, SMSSubscriber models"""

    fixtures = [
        'example_gateways.json', 'auth_user.json', 'gateway.json',
        'phonebook.json', 'contact.json', 'dialer_setting.json',
        'sms_campaign.json', 'user_profile.json', 'message.json',
        'sms_message.json'
    ]

    def setUp(self):
        self.user = User.objects.get(username='******')

        self.sms_dialer_setting = UserProfile.objects.get(
            user=self.user).dialersetting
        self.sms_dialer_setting.save()

        self.smscampaign = SMSCampaign(name="SMS Campaign",
                                       user=self.user,
                                       sms_gateway_id=1,
                                       status=2)
        self.smscampaign.save()
        self.assertEqual(self.smscampaign.__unicode__(), u'SMS Campaign')

        self.sms = SMSMessage(
            message_id=1,
            sms_campaign_id=1,
            sms_gateway_id=1,
            sender=self.user,
            content_type_id=1,
            object_id=1,
            uuid=str(uuid1()),
        )
        self.sms.save()

        # Subscriber model
        self.smssubscriber = SMSCampaignSubscriber(
            message_id=1,
            sms_campaign=self.smscampaign,
            contact_id=1,
            count_attempt=0,
            duplicate_contact=1,
            status=1)
        self.smssubscriber.save()
        self.assertTrue(self.smssubscriber.__unicode__())

        # Test mgt command
        call_command("create_sms", "1|10")

    def test_campaign_form(self):
        self.assertEqual(self.smscampaign.name, "SMS Campaign")
        SMSCampaign.objects.get_running_sms_campaign()
        SMSCampaign.objects.get_expired_sms_campaign()

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.PAUSE
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk,
                                    self.smscampaign.status)

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.ABORT
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk,
                                    self.smscampaign.status)

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.END
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk,
                                    self.smscampaign.status)

        self.smscampaign.is_authorized_contact('123456789')

        self.smscampaign.get_active_max_frequency()
        self.smscampaign.get_active_contact()
        self.smscampaign.progress_bar()
        self.smscampaign.sms_campaignsubscriber_detail()
        self.smscampaign.get_pending_subscriber()
        self.smscampaign.get_pending_subscriber_update()

        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.START)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.PAUSE)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.ABORT)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.END)

        self.assertEqual(self.smssubscriber.sms_campaign, self.smscampaign)

    def teardown(self):
        self.smscampaign.delete()
        self.smssubscriber.delete()
Example #3
0
class SMSCampaignModel(TestCase):
    """Test SMSCampaign, SMSSubscriber models"""

    fixtures = ['example_gateways.json', 'auth_user.json', 'gateway.json',
                'phonebook.json', 'contact.json', 'dialer_setting.json',
                'sms_campaign.json', 'user_profile.json', 'message.json',
                'sms_message.json']

    def setUp(self):
        self.user = User.objects.get(username='******')

        self.sms_dialer_setting = UserProfile.objects.get(user=self.user).dialersetting
        self.sms_dialer_setting.save()

        self.smscampaign = SMSCampaign(
            name="SMS Campaign",
            user=self.user,
            sms_gateway_id=1,
            status=2
        )
        self.smscampaign.save()
        self.assertEqual(self.smscampaign.__unicode__(), u'SMS Campaign')

        self.sms = SMSMessage(
            message_id=1,
            sms_campaign_id=1,
            sms_gateway_id=1,
            sender=self.user,
            content_type_id=1,
            object_id=1,
            uuid=str(uuid1()),
        )
        self.sms.save()

        # Subscriber model
        self.smssubscriber = SMSCampaignSubscriber(
            message_id=1,
            sms_campaign=self.smscampaign,
            contact_id=1,
            count_attempt=0,
            duplicate_contact=1,
            status=1
        )
        self.smssubscriber.save()
        self.assertTrue(self.smssubscriber.__unicode__())

        # Test mgt command
        call_command("create_sms", "1|10")

    def test_campaign_form(self):
        self.assertEqual(self.smscampaign.name, "SMS Campaign")
        SMSCampaign.objects.get_running_sms_campaign()
        SMSCampaign.objects.get_expired_sms_campaign()

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.PAUSE
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk, self.smscampaign.status)

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.ABORT
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk, self.smscampaign.status)

        self.smscampaign.status = SMS_CAMPAIGN_STATUS.END
        self.smscampaign.save()
        self.smscampaign.update_sms_campaign_status()
        get_sms_campaign_status_url(self.smscampaign.pk, self.smscampaign.status)

        self.smscampaign.is_authorized_contact('123456789')

        self.smscampaign.get_active_max_frequency()
        self.smscampaign.get_active_contact()
        self.smscampaign.progress_bar()
        self.smscampaign.sms_campaignsubscriber_detail()
        self.smscampaign.get_pending_subscriber()
        self.smscampaign.get_pending_subscriber_update()

        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.START)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.PAUSE)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.ABORT)
        self.smscampaign.common_sms_campaign_status(SMS_CAMPAIGN_STATUS.END)

        self.assertEqual(self.smssubscriber.sms_campaign, self.smscampaign)

    def teardown(self):
        self.smscampaign.delete()
        self.smssubscriber.delete()