コード例 #1
0
ファイル: test_api.py プロジェクト: ccnmtl/mediathread
    def test_dehydrate(self):
        res = SherdNoteResource()
        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        bundle = SherdNoteResource().build_bundle(
            obj=self.note1, request=request)

        res.dehydrate(bundle)
        self.assertEquals(bundle.data['vocabulary'], [])
        self.assertEquals(bundle.data['is_null'], False)
        self.assertEquals(bundle.data['editable'], True)
        self.assertEquals(bundle.data['is_global_annotation'], False)
        self.assertEquals(bundle.data['citable'], True)
コード例 #2
0
ファイル: test_api.py プロジェクト: tmnogueira/mediathread
    def test_dehydrate(self):
        res = SherdNoteResource()
        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        bundle = SherdNoteResource().build_bundle(obj=self.note1,
                                                  request=request)

        res.dehydrate(bundle)
        self.assertEquals(bundle.data['vocabulary'], [])
        self.assertEquals(bundle.data['is_null'], False)
        self.assertEquals(bundle.data['editable'], True)
        self.assertEquals(bundle.data['is_global_annotation'], False)
        self.assertEquals(bundle.data['citable'], True)
コード例 #3
0
ファイル: test_api.py プロジェクト: ccnmtl/mediathread
    def test_in_selection_assignment_response(self):
        res = SherdNoteResource()
        self.assertFalse(res.in_selection_assignment_response(self.note1))

        pn = ProjectNoteFactory(annotation=self.note1)
        pn.project.date_submitted = datetime.today()
        pn.project.save()
        self.assertTrue(res.in_selection_assignment_response(self.note1))

        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        request.course = self.sample_course
        bundle = SherdNoteResource().build_bundle(
            obj=self.note1, request=request)
        res.dehydrate(bundle)
        self.assertEquals(bundle.data['editable'], False)
        self.assertEquals(bundle.data['citable'], True)
コード例 #4
0
ファイル: test_api.py プロジェクト: tmnogueira/mediathread
    def test_in_selection_assignment_response(self):
        res = SherdNoteResource()
        self.assertFalse(res.in_selection_assignment_response(self.note1))

        pn = ProjectNoteFactory(annotation=self.note1)
        pn.project.date_submitted = datetime.today()
        pn.project.save()
        self.assertTrue(res.in_selection_assignment_response(self.note1))

        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        request.course = self.sample_course
        bundle = SherdNoteResource().build_bundle(obj=self.note1,
                                                  request=request)
        res.dehydrate(bundle)
        self.assertEquals(bundle.data['editable'], False)
        self.assertEquals(bundle.data['citable'], True)
コード例 #5
0
ファイル: test_api.py プロジェクト: ccnmtl/mediathread
    def test_in_sequence_assignment_response(self):
        res = SherdNoteResource()
        self.assertFalse(res.in_sequence_assignment_response(self.note1))
        self.assertFalse(res.in_sequence_assignment_response(self.note2))

        sa = SequenceAssetFactory(spine=self.note1)
        psa = ProjectSequenceAssetFactory(sequence_asset=sa)
        self.assertFalse(res.in_sequence_assignment_response(self.note1))

        psa.project.date_submitted = datetime.today()
        psa.project.save()
        self.assertTrue(res.in_sequence_assignment_response(self.note1))

        SequenceMediaElementFactory(sequence_asset=sa, media=self.note2)
        self.assertTrue(res.in_sequence_assignment_response(self.note2))

        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        request.course = self.sample_course
        bundle = SherdNoteResource().build_bundle(
            obj=self.note1, request=request)
        res.dehydrate(bundle)
        self.assertEquals(bundle.data['editable'], False)
        self.assertEquals(bundle.data['citable'], True)
コード例 #6
0
ファイル: test_api.py プロジェクト: tmnogueira/mediathread
    def test_in_sequence_assignment_response(self):
        res = SherdNoteResource()
        self.assertFalse(res.in_sequence_assignment_response(self.note1))
        self.assertFalse(res.in_sequence_assignment_response(self.note2))

        sa = SequenceAssetFactory(spine=self.note1)
        psa = ProjectSequenceAssetFactory(sequence_asset=sa)
        self.assertFalse(res.in_sequence_assignment_response(self.note1))

        psa.project.date_submitted = datetime.today()
        psa.project.save()
        self.assertTrue(res.in_sequence_assignment_response(self.note1))

        SequenceMediaElementFactory(sequence_asset=sa, media=self.note2)
        self.assertTrue(res.in_sequence_assignment_response(self.note2))

        request = RequestFactory().get('/?citable=true')
        request.user = self.student_one
        request.course = self.sample_course
        bundle = SherdNoteResource().build_bundle(obj=self.note1,
                                                  request=request)
        res.dehydrate(bundle)
        self.assertEquals(bundle.data['editable'], False)
        self.assertEquals(bundle.data['citable'], True)