mercredi 21 octobre 2015

AssertionError: 302 != 200

I tried to create a test in my tests.py

class TaskViewTests(TestCase):
    def test_task_view_with_no_task(self):
        """
        If no task exist, an appropriate message should be displayed.
        """
        userName = 'esutek'
        response = self.client.get(reverse('actuser:task',args=(userName,)))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "No task are available.")
        self.assertQuerysetEqual(response.context['taskList'], [])

However it gives me this error message. I don't have any clue why this happened. I just followed the tutorial.

actuser:task views.py

def task(request, userName):
    """ User task list in actInbox
    """

    user = ActuserViewModel()
    user.get_task_list(userName)

    return render(request, 'actuser/task.html', {
                'userName': userName,
                'taskList': user.taskList,
                'dateToday': user.dateToday,
           })

viewmodels.py

def get_task_list(self, userName):
    self.taskList = Task.objects.filter(executor = userName, parent_task_id=EMPTY_UUID).order_by('due_date')
    #get date now with this format 05/11
    self.dateToday = datetime.date.today()

Aucun commentaire:

Enregistrer un commentaire