def setUp(self): self.user = User.objects.get(username='******') # Phonebook model self.phonebook = Phonebook( name='test_phonebook', user=self.user, ) self.phonebook.save() # Contact model self.contact = Contact( phonebook=self.phonebook, contact=123456789, first_name='Tom', last_name='Gun', ) self.contact.save() self.assertEqual(self.contact.__unicode__(), u'123456789 (Gun)') self.assertEqual(self.contact.contact_name(), 'Tom Gun') self.assertTrue(get_url_campaign_status(1, 1)) self.assertTrue(get_url_campaign_status(1, 2)) self.assertTrue(get_url_campaign_status(1, 3)) self.assertTrue(get_url_campaign_status(1, 4))
def get_campaign_status_url(id, status): return get_url_campaign_status(id, status)
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 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)