def test_student_picture_unknown(self, mock_request_get): student_m = StudentFactory(person=PersonFactory( last_name='Durant', first_name='Thomas', gender='M')) student_f = StudentFactory(person=PersonFactory( last_name='Durant', first_name='Alice', gender='F')) from base.views.student import student_picture from django.contrib.staticfiles.storage import staticfiles_storage request = RequestFactory().get( reverse(student_picture, args=[student_m.id])) request.user = self.program_manager_1.person.user response = student_picture(request, student_m.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.url, staticfiles_storage.url('img/men_unknown.png')) request = RequestFactory().get( reverse(student_picture, args=[student_f.id])) request.user = self.program_manager_1.person.user response = student_picture(request, student_f.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.url, staticfiles_storage.url('img/women_unknown.png'))
def test_student_picture_unknown(self, mock_request_get): from base.views.student import student_picture from django.contrib.staticfiles.storage import staticfiles_storage request = RequestFactory().get(reverse(student_picture, args=[self.student_m.id])) request.user = self.program_manager.person.user response = student_picture(request, self.student_m.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.url, staticfiles_storage.url('img/men_unknown.png')) request = RequestFactory().get(reverse(student_picture, args=[self.student_f.id])) request.user = self.program_manager.person.user response = student_picture(request, self.student_f.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.url, staticfiles_storage.url('img/women_unknown.png'))
def test_student_picture(self, mock_request_get): from base.views.student import student_picture mock_response = Mock() mock_response.json.return_value = {'photo_url': 'awesome/photo.png'} mock_response.content = b"an image" mock_response.status_code = 200 mock_request_get.return_value = mock_response request = RequestFactory().get(reverse(student_picture, args=[self.student_m.id])) request.user = self.program_manager.person.user response = student_picture(request, self.student_m.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.content, b'an image')
def test_student_picture(self, mock_request_get): student_m = StudentFactory(person=PersonFactory( last_name='Durant', first_name='Thomas', gender='M')) from base.views.student import student_picture mock_response = Mock() mock_response.json.return_value = {'photo_url': 'awesome/photo.png'} mock_response.content = b"an image" mock_response.status_code = 200 mock_request_get.return_value = mock_response request = RequestFactory().get( reverse(student_picture, args=[student_m.id])) request.user = self.program_manager_1.person.user response = student_picture(request, student_m.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.content, b'an image')