예제 #1
0
    def test_section_branch_change(self):
        """Test Function section branching update"""
        self.section = Section_template.objects.get(pk=1)
        self.goto = Section_template.objects.get(pk=2)

        branching_obj = Branching_template.objects.create(
            keys=34,
            section=self.section,
            goto=self.goto
        )

        request = self.factory.get('/section/branch/' + str(branching_obj.id) + '/')
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, branching_obj.id)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/section/branch/'+str(branching_obj.id)+'/',
            {'keys': 1, 'section': self.section,
             'goto': self.goto}, follow=True)
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, branching_obj.id)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/section/branch/'+str(branching_obj.id)+'/?delete=true',
            {'keys': 1, 'section': self.section,
             'goto': self.goto}, follow=True)
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, branching_obj.id)
        self.assertEqual(response.status_code, 302)
예제 #2
0
    def test_section_branch_change(self):
        """Test Function section branching update"""
        self.section = Section.objects.get(pk=1)
        self.goto = Section.objects.get(pk=2)

        request = self.factory.get('/section/branch/1/')
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, 1)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/section/branch/1/',
            {'keys': 1, 'section': self.section,
             'goto': self.goto}, follow=True)
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, 1)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/section/branch/1/',
            {}, follow=True)
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, 1)
        self.assertEqual(response.status_code, 200)

        request = self.factory.post('/section/branch/1/?delete=true',
            {'keys': 1, 'section': self.section,
             'goto': self.goto}, follow=True)
        request.user = self.user
        request.session = {}
        response = section_branch_change(request, 1)
        self.assertEqual(response.status_code, 302)