def test_upvote(self): c = SocialClient() response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 302) c.login(self.user, backend='facebook') response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 200) u = User.objects.get(email='*****@*****.**') u.profile.locality = self.common_user.profile.locality u.profile.save() self.mock_request.return_value.content = json.dumps({'id': 1}) response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 403) self.assertEquals(response.content, 'You already upvoted this question') self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:join', files={}, data={ 'question': 'http://example.com%s' % self.q.get_absolute_url(), 'access_token': 'dummyToken' }) response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 403) self.assertEquals(response.content, 'You already upvoted this question')
def test_upvote(self): c = SocialClient() response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 302) c.login(self.user, backend='facebook') u=User.objects.get(email='*****@*****.**') u.profile.locality = self.common_user.profile.locality u.profile.save() self.mock_request.return_value.content = json.dumps({ 'id': 1 }) response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 200) response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 403) self.assertEquals(response.content, 'You already upvoted this question') self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:join', files={}, data={ 'question': 'http://example.com%s' % self.q.get_absolute_url(), 'access_token': 'dummyToken' } ) response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 403) self.assertEquals(response.content, 'You already upvoted this question')
def test_upvote(self): c = SocialClient() response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 302) c.login(self.user, backend='facebook') response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 200) self.assertEquals(response.content, "2") response = c.post(reverse('upvote_question', kwargs={'q_id':self.q.id})) self.assertEquals(response.status_code, 403)
def test_upvote(self): c = SocialClient() response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 302) c.login(self.user, backend='facebook') response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 200) self.assertEquals(response.content, "2") response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 403)
def test_post_question_facebook(self): c = SocialClient() c.login(self.user, backend='facebook') u = User.objects.get(email='*****@*****.**') u.profile.locality = self.entity u.profile.save() post_url = reverse('post_question', args=(self.entity.slug, )) self.mock_request.return_value.content = json.dumps({'id': 1}) response = c.post( post_url, { 'subject': "Where?", 'facebook_publish': 'on', 'entity': self.entity.id, }) self.assertEquals(response.status_code, 302) new_q = Question.objects.get(subject="Where?") self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:ask', files={}, data={ 'question': 'http://example.com%s' % new_q.get_absolute_url(), 'access_token': 'dummyToken' })
def test_post_question_facebook(self): c = SocialClient() c.login(self.user, backend='facebook') u=User.objects.get(email='*****@*****.**') u.profile.locality = self.home u.profile.is_candidate = True u.profile.save() post_url = reverse('post_answer', args=(self.q.id, )) self.mock_request.return_value.content = json.dumps({ 'id': 1 }) response = c.post(post_url, {'content':"42", }) self.assertEquals(response.status_code, 302) new_a=Answer.objects.get(content="42") self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:answer', files={}, data={ 'question': 'http://example.com%s' % new_a.get_absolute_url(), 'access_token': 'dummyToken' } )
def test_post_question_facebook(self): c = SocialClient() c.login(self.user, backend='facebook') u=User.objects.get(email='*****@*****.**') u.profile.locality = self.home u.profile.save() post_url = reverse('post_question') self.mock_request.return_value.content = json.dumps({ 'id': 1 }) response = c.post(post_url, {'subject':"Where?", 'facebook_publish': 'on', 'home': self.home.id, }) self.assertEquals(response.status_code, 302) new_q=Question.objects.get(subject="Where?") self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:ask', files={}, data={ 'question': 'http://example.com%s' % new_q.get_absolute_url(), 'access_token': 'dummyToken' } )
def test_post_question_facebook(self): c = SocialClient() c.login(self.user, backend='facebook') u=User.objects.get(email='*****@*****.**') u.profile.locality = self.entity u.profile.is_candidate = True u.profile.save() post_url = reverse('post_answer', args=(self.q.id, )) self.mock_request.return_value.content = json.dumps({ 'id': 1 }) response = c.post(post_url, {'content':"42", }) self.assertEquals(response.status_code, 302) new_a=Answer.objects.get(content="42") self.mock_request.assert_called_with( 'POST', 'https://graph.facebook.com/me/localshot:answer', files={}, data={ 'question': 'http://example.com%s' % new_a.get_absolute_url(), 'access_token': 'dummyToken' } )
def test_upvote(self): c = SocialClient() response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 302) c.login(self.user, backend='facebook') response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertRedirects( response, '%s?next=%s' % (reverse("edit_profile"), reverse('upvote_question', kwargs={'q_id': self.q.id}))) u = User.objects.get(email='*****@*****.**') u.profile.locality = self.common_user.profile.locality u.profile.save() response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 200) self.assertEquals(response.content, "2") response = c.post( reverse('upvote_question', kwargs={'q_id': self.q.id})) self.assertEquals(response.status_code, 403)