def test_project_edit(self): # I'm unsure how to test with logged user using djangoae # Using request factory to bypass that. request = self.rf.get('/projects/%s/edit/' % self.project.id) request.user = self.user r = update_project_view(request, project_id=self.project.id) self.assertEqual(r.status_code, 200) r.render() self.assertIn(u'Edit', r.content.decode('utf8'))
def test_user_update_project_view_post_success(self): new_title = 'Changed Title' request = self.rf.post(reverse('project-update', kwargs=self.project_kwargs), {'title': new_title}) request.user = self.user response = views.update_project_view(request, **self.project_kwargs) assert_code(response, 302) eq_(response['location'], reverse('project-list')) project = Project.objects.get(pk=self.test_project.pk) ok_(project.title == new_title)
def test_user_update_project_view_post_error(self): request = self.rf.post(reverse('project-update', kwargs=self.project_kwargs)) request.user = self.user response = views.update_project_view(request, **self.project_kwargs) ok_(not response.context_data['form'].is_valid())
def test_user_update_project_view_get(self): request = self.rf.get(reverse('project-update', kwargs=self.project_kwargs)) request.user = self.user response = views.update_project_view(request, **self.project_kwargs) assert_code(response, 200) ok_(response.render())