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

        # Campaign model
        try:
            self.content_type_id = \
                ContentType.objects.get(model='survey_template').id
        except:
            self.content_type_id = 1

        self.campaign = Campaign(name="sample_campaign",
                                 user=self.user,
                                 aleg_gateway_id=1,
                                 content_type_id=self.content_type_id,
                                 object_id=1,
                                 status=1)
        self.campaign.save()
        self.assertEqual(self.campaign.__unicode__(), u'sample_campaign')

        # Subscriber model
        self.subscriber = Subscriber(contact_id=1,
                                     campaign=self.campaign,
                                     count_attempt=0,
                                     completion_count_attempt=0,
                                     status=1)
        self.subscriber.save()
        self.assertTrue(self.subscriber.__unicode__())

        # Test mgt command
        call_command("create_subscriber", "123456|1")

        call_command("create_subscriber", "123456|3")
Exemple #2
0
    def setUp(self):
        self.user = User.objects.get(username='******')

        # Campaign model
        try:
            self.content_type_id = ContentType.objects.get(model='survey_template').id
        except:
            self.content_type_id = 1

        self.campaign = Campaign(
            name="sample_campaign",
            user=self.user,
            aleg_gateway_id=1,
            content_type_id=self.content_type_id,
            object_id=1,
            status=1
        )
        self.campaign.save()
        self.assertEqual(self.campaign.__unicode__(), u'sample_campaign')

        # Subscriber model
        self.subscriber = Subscriber(
            contact_id=1,
            campaign=self.campaign,
            count_attempt=0,
            completion_count_attempt=0,
            status=1
        )
        self.subscriber.save()
        self.assertTrue(self.subscriber.__unicode__())

        # Test mgt command
        call_command("create_subscriber", "123456|1")

        call_command("create_subscriber", "123456|3")
Exemple #3
0
class DialerCampaignModel(TestCase):
    """Test Campaign, Subscriber models"""

    fixtures = ['auth_user.json', 'gateway.json',
                'dialer_setting.json', 'user_profile.json',
                'phonebook.json', 'contact.json', 'survey.json',
                'dnc_list.json', 'dnc_contact.json',
                'campaign.json', 'subscriber.json',
                ]

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

        # Campaign model
        try:
            self.content_type_id = ContentType.objects.get(model='survey_template').id
        except:
            self.content_type_id = 1

        self.campaign = Campaign(
            name="sample_campaign",
            user=self.user,
            aleg_gateway_id=1,
            content_type_id=self.content_type_id,
            object_id=1,
            status=1
        )
        self.campaign.save()
        self.assertEqual(self.campaign.__unicode__(), u'sample_campaign')

        # Subscriber model
        self.subscriber = Subscriber(
            contact_id=1,
            campaign=self.campaign,
            count_attempt=0,
            completion_count_attempt=0,
            status=1
        )
        self.subscriber.save()
        self.assertTrue(self.subscriber.__unicode__())

        # Test mgt command
        call_command("create_subscriber", "123456|1")

        call_command("create_subscriber", "123456|3")

    def test_campaign_form(self):
        self.assertEqual(self.campaign.name, "sample_campaign")

        Campaign.objects.get_running_campaign()
        Campaign.objects.get_expired_campaign()
        dialersetting = DialerSetting.objects.get(pk=1)
        #self.user.get_profile().dialersetting
        common_contact_authorization(dialersetting, '1234567890')

        # status = 1
        self.campaign.update_campaign_status()
        get_campaign_status_url(self.campaign.pk, self.campaign.status)

        self.campaign.status = 2
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_campaign_status_url(self.campaign.pk, self.campaign.status)

        self.campaign.status = 3
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_campaign_status_url(self.campaign.pk, self.campaign.status)

        self.campaign.status = 4
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_campaign_status_url(self.campaign.pk, self.campaign.status)

        self.campaign.is_authorized_contact(dialersetting, '123456789')
        self.campaign.get_active_max_frequency()
        self.campaign.get_active_callmaxduration()
        self.campaign.get_active_contact()
        self.campaign.progress_bar()
        self.campaign.subscriber_detail()
        self.campaign.get_pending_subscriber_update(10, SUBSCRIBER_STATUS.IN_PROCESS)

        self.assertEqual(self.subscriber.campaign, self.campaign)

        form = CampaignForm(self.user)
        obj = form.save(commit=False)
        obj.name = "new_campaign"
        obj.user = self.user
        obj.phonebook_id = 1
        obj.aleg_gateway_id = 1
        obj.content_type_id = self.content_type_id
        obj.object_id = 1
        obj.save()

        form = CampaignForm(self.user, instance=self.campaign)
        self.assertTrue(isinstance(form.instance, Campaign))

        form = CampaignForm(self.user, data={
            "name": "mylittle_campaign",
            "description": "xyz",
            "startingdate": "1301392136.0",
            "expirationdate": "1301332136.0",
            "frequency": "120",
            "callmaxduration": "50",
            "maxretry": "3",
            "intervalretry": "2000",
            "calltimeout": "60",
            "aleg_gateway": "1",
            "sms_gateway": "",
            "content_object": "type:32-id:1",
            "extra_data": "2000"})
        self.assertEquals(form.is_valid(), False)

    def teardown(self):
        self.campaign.delete()
        self.subscriber.delete()
Exemple #4
0
class DialerCampaignModel(TestCase):
    """Test Campaign, Subscriber models"""

    fixtures = [
        'auth_user.json',
        'gateway.json',
        'dialer_setting.json',
        'user_profile.json',
        'phonebook.json',
        'contact.json',
        'survey.json',
        'dnc_list.json',
        'dnc_contact.json',
        'campaign.json',
        'subscriber.json',
    ]

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

        # Campaign model
        try:
            self.content_type_id = \
                ContentType.objects.get(model='survey_template').id
        except:
            self.content_type_id = 1

        self.campaign = Campaign(name="sample_campaign",
                                 user=self.user,
                                 aleg_gateway_id=1,
                                 content_type_id=self.content_type_id,
                                 object_id=1,
                                 status=1)
        self.campaign.save()
        self.assertEqual(self.campaign.__unicode__(), u'sample_campaign')

        # Subscriber model
        self.subscriber = Subscriber(contact_id=1,
                                     campaign=self.campaign,
                                     count_attempt=0,
                                     completion_count_attempt=0,
                                     status=1)
        self.subscriber.save()
        self.assertTrue(self.subscriber.__unicode__())

        # Test mgt command
        call_command("create_subscriber", "123456|1")

        call_command("create_subscriber", "123456|3")

    def test_campaign_form(self):
        self.assertEqual(self.campaign.name, "sample_campaign")

        Campaign.objects.get_running_campaign()
        Campaign.objects.get_expired_campaign()
        dialersetting = DialerSetting.objects.get(pk=1)
        #self.user.get_profile().dialersetting
        common_contact_authorization(dialersetting, '1234567890')

        # status = 1
        self.campaign.update_campaign_status()
        get_url_campaign_status(self.campaign.pk, self.campaign.status)

        self.campaign.status = 2
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_url_campaign_status(self.campaign.pk, self.campaign.status)

        self.campaign.status = 3
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_url_campaign_status(self.campaign.pk, self.campaign.status)

        self.campaign.status = 4
        self.campaign.save()
        self.campaign.update_campaign_status()
        get_url_campaign_status(self.campaign.pk, self.campaign.status)

        self.campaign.is_authorized_contact(dialersetting, '123456789')
        self.campaign.get_active_max_frequency()
        self.campaign.get_active_callmaxduration()
        self.campaign.get_active_contact()
        self.campaign.progress_bar()
        self.campaign.subscriber_detail()
        self.campaign.get_pending_subscriber_update(
            10, SUBSCRIBER_STATUS.IN_PROCESS)

        self.assertEqual(self.subscriber.campaign, self.campaign)

        form = CampaignForm(self.user)
        obj = form.save(commit=False)
        obj.name = "new_campaign"
        obj.user = self.user
        obj.phonebook_id = 1
        obj.aleg_gateway_id = 1
        obj.content_type_id = self.content_type_id
        obj.object_id = 1
        obj.save()

        form = CampaignForm(self.user, instance=self.campaign)
        self.assertTrue(isinstance(form.instance, Campaign))

        form = CampaignForm(self.user,
                            data={
                                "name": "mylittle_campaign",
                                "description": "xyz",
                                "startingdate": "1301392136.0",
                                "expirationdate": "1301332136.0",
                                "frequency": "120",
                                "callmaxduration": "50",
                                "maxretry": "3",
                                "intervalretry": "2000",
                                "calltimeout": "60",
                                "aleg_gateway": "1",
                                "content_object": "type:32-id:1",
                                "extra_data": "2000",
                                "ds_user": self.user
                            })
        self.assertEquals(form.is_valid(), False)

    def teardown(self):
        self.campaign.delete()
        self.subscriber.delete()