def test_signup_POST_sent_to_form(self, mock_form): mock_a_form = mock_form.return_value mock_a_form.is_valid.return_value = True # mock_a_form(data=self.request.POST) signup(self.request) mock_form.assert_called_once_with(data=self.request.POST)
def test_renders_correct_html(self, mock_render, mock_form): self.request.method = 'GET' mock_a_form = mock_form.return_value signup(self.request) # response.client = Client() mock_render.assert_called_once_with(self.request, 'accounts/signup.html', {'form': mock_a_form})
def test_confirmation_email_is_sent(self, mock_form): mock_a_form = mock_form.return_value mock_a_form.is_valid.return_value = True mock_a_form.save.return_value = Mock(data=self.request.POST) mock_user = mock_a_form.save.return_value signup(self.request) email = mail.outbox[0] self.assertIn(mock_user.email, email.to) self.assertEqual(email.subject, 'Activate Your Supertodolists Account')
def game_start(request): games = Game.objects.all().order_by('date') response = signup(request) if response[ 'user_created']: #if user is created we are directing them to game 1 return render(request, 'retailPrice/retailPrice_start.html') else: #else we are redirecting them back to homepage for now return render(request, 'game/game_start.html', { 'games': games, 'form': response['form'], })
def home_page(request): if request.user.is_authenticated(): # print request.user.id # print os.path.dirname(os.path.abspath(__file__)) # print __file__ print 'user is authenticated in the home page' userImageName = getProfilePicture(request.user.id) print MEDIA_URL print str(userImageName) home_url = "http://127.0.0.1:8000" return render(request, 'home.html', {'picture':userImageName, 'home_url': home_url,\ 'MEDIA_URL': MEDIA_URL}) else: return signup(request)
def test_doesnot_save_if_form_invalid(self, mock_form): mock_a_form = mock_form.return_value mock_a_form.is_valid.return_value = False signup(self.request) self.assertFalse(mock_a_form.save.called)
def test_saves_user_after_save_method(self, mock_form): mock_a_form = mock_form.return_value signup(self.request) mock_a_form.save.assert_called_once()
def test_redirects_to_home_page(self, mock_form): response = signup(self.request) response.client = Client() self.assertRedirects(response, '/')