Exemplo n.º 1
0
    def test_workflow_list_get(self):
        # set dates to test reverse chron ordering
        self.workflow1.creation_date = "2010-10-20 1:23Z"
        self.workflow1.save()
        self.workflow2 = Workflow.objects.create(
            name='Workflow 2',
            owner=self.user,
            creation_date='2015-09-18 2:34Z')

        request = self._build_get('/api/workflows/', user=self.user)
        response = render_workflows(request)
        self.assertIs(response.status_code, status.HTTP_200_OK)

        workflows = response.context_data['initState']['workflows']
        # should not pick up other user's workflows, even public ones
        self.assertEqual(
            len(workflows['owned']) + len(workflows['shared']) +
            len(workflows['templates']), 2)

        self.assertEqual(workflows['owned'][0]['name'], 'Workflow 2')
        self.assertEqual(workflows['owned'][0]['id'], self.workflow2.id)
        self.assertEqual(workflows['owned'][0]['public'],
                         self.workflow1.public)
        self.assertEqual(workflows['owned'][0]['read_only'],
                         False)  # user is owner
        self.assertEqual(workflows['owned'][0]['is_owner'],
                         True)  # user is owner
        self.assertIsNotNone(workflows['owned'][0]['last_update'])
        self.assertEqual(workflows['owned'][0]['owner_name'],
                         user_display(self.workflow2.owner))

        self.assertEqual(workflows['owned'][1]['name'], 'Workflow 1')
        self.assertEqual(workflows['owned'][1]['id'], self.workflow1.id)
Exemplo n.º 2
0
    def test_workflow_list_exclude_lesson(self):
        self.workflow1.lesson_slug = 'some-lesson'
        self.workflow1.save()

        request = self._build_get('/api/workflows/', user=self.user)
        response = render_workflows(request)
        workflows = response.context_data['initState']['workflows']
        self.assertIs(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(workflows['owned']), 1)
Exemplo n.º 3
0
    def test_workflow_list_exclude_example_not_in_all_users_lists(self):
        self.other_workflow_public.example = True
        self.other_workflow_public.in_all_users_workflow_lists = False
        self.other_workflow_public.save()

        request = self._build_get('/api/workflows/', user=self.user)
        response = render_workflows(request)
        self.assertIs(response.status_code, status.HTTP_200_OK)

        workflows = response.context_data['initState']['workflows']
        self.assertEqual(len(workflows['owned']), 2)
        self.assertEqual(len(workflows['templates']), 0)