class ConferenceResponseViewTestCase(TestCase): def setUp(self): self.organization = Organization(name='Foo Org') self.organization.save() self.phone_number = PhoneNumber(organization=self.organization, twilio_sid='xxx', phone_number='+15550009999') self.phone_number.save() self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') self.user.userprofile.phone_number = "5556667777" self.user.userprofile.save() self.conference = Conference(organization=self.organization, name='My Conf', phone_number=self.phone_number) self.conference.save() def test_incoming_call(self): self.conference.user_set.add(self.user) call = Call(conference=self.conference, user=self.user, twilio_sid='888') call.save() self.assertEquals(call.call_state, call.INCOMING) url = reverse('conference_response', args=(self.conference.id,)) resp = self.client.post(url, {'CallSid':call.twilio_sid}) #self.assertContains(resp.content, self.conference.name) call_result = Call.objects.get(id=call.id) self.assertEquals(call_result.call_state, Call.IN_CALL) self.assertTrue(CallEvent.objects.filter(call=call, event_type=CallEvent.JOIN).exists())
def ConferenceRegistration(request): baseUrl = "../" if not request.user.is_authenticated(): return HttpResponseRedirect(baseUrl + 'login/') if request.method =='POST': # If they're in the process of filling out a form #data = request.POST.copy() #data['slug'] = "a" # slugs are handled inside the model, this forces the check to pass form = ConferenceForm(request.POST) if form.is_valid(): conference = Conference( name=form.cleaned_data['name'], description=form.cleaned_data['description'], start_date=form.cleaned_data['start_date'], end_date=form.cleaned_data['end_date'], twitter=form.cleaned_data['twitter'], website=form.cleaned_data['website'], guests=form.cleaned_data['guests'], gmaps=form.cleaned_data['gmaps'], user=request.user) conference.save() #pic = PhotoUpload(con = conference, picture=form.cleaned_data['pictures']) return HttpResponseRedirect(baseUrl + 'profile/') else: context = { 'form' : form, 'baseUrl' : baseUrl } return render_to_response('reg_con.html', context, context_instance=RequestContext(request)) else: # Show the user a blank registration form form = ConferenceForm() context = {'form': form, 'baseUrl': baseUrl} return render_to_response('reg_con.html', context, context_instance=RequestContext(request))
def test_multiple_enable(self): """ Test that there can only be one conference enabled at a time. """ pycon = Conference( name="PyCon Philippines 2012", starts=timezone.now(), ends=timezone.now() + timedelta(days=1), description="Python Conference Philippines 2012", is_enabled=True, ) pycon.save() pycon = Conference( name="PyCon Philippines 2013", starts=timezone.now(), ends=timezone.now() + timedelta(days=1), description="Python Conference Philippines 2013", is_enabled=True, ) self.assertRaises(exceptions.ValidationError, pycon.full_clean)
class ConferenceResponseViewTestCase(TestCase): def setUp(self): self.organization = Organization(name='Foo Org') self.organization.save() self.phone_number = PhoneNumber(organization=self.organization, twilio_sid='xxx', phone_number='+15550009999') self.phone_number.save() self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******') self.user.userprofile.phone_number = "5556667777" self.user.userprofile.save() self.conference = Conference(organization=self.organization, name='My Conf', phone_number=self.phone_number) self.conference.save() def test_incoming_call(self): self.conference.user_set.add(self.user) call = Call(conference=self.conference, user=self.user, twilio_sid='888') call.save() self.assertEquals(call.call_state, call.INCOMING) url = reverse('conference_response', args=(self.conference.id, )) resp = self.client.post(url, {'CallSid': call.twilio_sid}) #self.assertContains(resp.content, self.conference.name) call_result = Call.objects.get(id=call.id) self.assertEquals(call_result.call_state, Call.IN_CALL) self.assertTrue( CallEvent.objects.filter(call=call, event_type=CallEvent.JOIN).exists())