Ejemplo n.º 1
0
    def test_migrate_tags_and_notes(self):
        data = {
            'fromCourse': self.sample_course.id,
            'asset_ids[]': [self.asset1.id],
            'project_ids[]': [],
            'include_tags': 'true',
            'include_notes': 'true'
        }

        # Migrate assets from SampleCourse into Alternate Course
        # test_instructor_three is a member of both courses
        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.instructor_three
        request.course = self.alt_course

        view = MigrateCourseView()
        view.request = request
        view.post(request)

        new_asset = Asset.objects.get(course=self.alt_course,
                                      title=self.asset1.title)
        self.assertEquals(new_asset.sherdnote_set.count(), 2)

        note = new_asset.sherdnote_set.get(title=self.instructor_note.title)
        self.assertEquals(note.tags, self.instructor_note.tags)
        self.assertEquals(note.body, self.instructor_note.body)

        note = new_asset.global_annotation(self.instructor_three, False)
        self.assertEquals(
            note.tags,
            u',image, instructor_one_global,,instructor_two_global,')
        self.assertEquals(
            note.body,
            u'instructor one global noteinstructor two global note')
Ejemplo n.º 2
0
    def test_get_context_data(self):
        request = RequestFactory().get('/dashboard/migrate/')
        request.user = self.instructor_three
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request

        ctx = view.get_context_data()

        self.assertEquals(len(ctx['current_course_faculty']), 3)
        self.assertEquals(ctx['current_course_faculty'][0].username,
                          'instructor_one')
        self.assertEquals(ctx['current_course_faculty'][1].username,
                          'instructor_three')
        self.assertEquals(ctx['current_course_faculty'][2].username,
                          'instructor_two')

        self.assertEquals(len(ctx['available_courses']), 2)
        self.assertEquals(ctx['available_courses'][0].title,
                          'Alternate Course')
        self.assertEquals(ctx['available_courses'][1].title,
                          'Sample Course')

        request.user = self.superuser
        ctx = view.get_context_data()
        self.assertEquals(len(ctx['available_courses']), 2)
        self.assertEquals(ctx['available_courses'][0].title,
                          'Alternate Course')
        self.assertEquals(ctx['available_courses'][1].title,
                          'Sample Course')
Ejemplo n.º 3
0
    def test_get_context_data(self):
        request = RequestFactory().get('/dashboard/migrate/')
        request.user = User.objects.get(username='******')
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request

        ctx = view.get_context_data()

        self.assertEquals(len(ctx['current_course_faculty']), 2)
        self.assertEquals(ctx['current_course_faculty'][0].username,
                          'test_instructor')
        self.assertEquals(ctx['current_course_faculty'][1].username,
                          'test_instructor_two')

        self.assertEquals(len(ctx['available_courses']), 2)
        self.assertEquals(ctx['available_courses'][0].title,
                          'Alternate Course')
        self.assertEquals(ctx['available_courses'][1].title,
                          'Sample Course')

        request.user = self.superuser
        ctx = view.get_context_data()
        self.assertEquals(len(ctx['available_courses']), 2)
        self.assertEquals(ctx['available_courses'][0].title,
                          'Alternate Course')
        self.assertEquals(ctx['available_courses'][1].title,
                          'Sample Course')
Ejemplo n.º 4
0
    def test_post_invalidcourse(self):
        data = {'fromCourse': 42}

        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.superuser
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request

        self.assertRaises(Http404, view.post, request)
Ejemplo n.º 5
0
    def test_post_invalidcourse(self):
        data = {
            'fromCourse': 23
        }

        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.superuser
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request

        self.assertRaises(Http404, view.post, request)
Ejemplo n.º 6
0
    def test_migrate_project(self):
        self.project1 = ProjectFactory.create(course=self.sample_course,
                                              author=self.instructor_one,
                                              policy='PublicEditorsAreOwners')

        self.add_citation(self.project1, self.instructor_note)
        self.add_citation(self.project1, self.student_note)
        self.assertEquals(len(self.project1.citations()), 2)

        data = {
            'fromCourse': self.sample_course.id,
            'asset_ids[]': [],
            'project_ids[]': [self.project1.id]
        }

        # Migrate assets from SampleCourse into Alternate Course
        # test_instructor_three is a member of both courses
        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.instructor_three
        request.course = self.alt_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertTrue(the_json['success'])
        self.assertEquals(the_json['asset_count'], 1)
        self.assertEquals(the_json['project_count'], 1)
        self.assertEquals(the_json['note_count'], 2)

        new_asset = Asset.objects.get(course=self.alt_course,
                                      title=self.asset1.title)
        self.assertEquals(new_asset.sherdnote_set.count(), 3)

        new_note = new_asset.sherdnote_set.get(title=self.student_note.title)
        self.assertEquals(new_note.author, self.instructor_three)

        new_note = new_asset.sherdnote_set.get(
            title=self.instructor_note.title)
        self.assertEquals(new_note.author, self.instructor_three)

        new_note = new_asset.sherdnote_set.get(title=None)
        self.assertEquals(new_note.author, self.instructor_three)
        self.assertTrue(new_note.is_global_annotation())

        new_project = Project.objects.get(
            course=self.alt_course, title=self.project1.title)
        self.assertEquals(len(new_project.citations()), 2)
Ejemplo n.º 7
0
    def test_post_on_behalf_of_faculty(self):
        data = {
            'fromCourse': self.alt_course.id,
            'on_behalf_of': self.alt_instructor.id
        }

        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.superuser
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertFalse(the_json['success'])
Ejemplo n.º 8
0
    def test_post_on_behalf_of_faculty(self):
        teacher = User.objects.get(username='******')
        data = {
            'fromCourse': self.alt_course.id,
            'on_behalf_of': teacher.id
        }

        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.superuser
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertFalse(the_json['success'])
Ejemplo n.º 9
0
    def test_post_on_behalf_of_student(self):
        student = User.objects.get(username='******')
        data = {
            'fromCourse': self.alt_course.id,
            'on_behalf_of': student.id
        }

        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.superuser
        request.course = self.sample_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertFalse(the_json['success'])
Ejemplo n.º 10
0
    def test_post(self):
        asset1 = Asset.objects.get(
            course=self.sample_course,
            title="The Armory - Home to CCNMTL'S CUMC Office")
        project1 = Project.objects.get(
            course=self.sample_course, title='Sample Course Assignment')
        data = {
            'fromCourse': self.sample_course.id,
            'asset_ids[]': [asset1.id],
            'project_ids[]': [project1.id]
        }

        # Migrate assets from SampleCourse into Alternate Course
        # test_instructor_two is a member of both courses
        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = User.objects.get(username='******')
        request.course = self.alt_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertTrue(the_json['success'])
        self.assertEquals(the_json['asset_count'], 4)
        self.assertEquals(the_json['project_count'], 1)
        self.assertEquals(the_json['note_count'], 6)

        Asset.objects.get(
            course=self.alt_course,
            title="The Armory - Home to CCNMTL'S CUMC Office")
        Asset.objects.get(
            course=self.alt_course,
            title="Mediathread: Introduction")
        Asset.objects.get(course=self.alt_course, title="MAAP Award Reception")
        Asset.objects.get(course=self.alt_course, title="Project Portfolio")

        project1 = Project.objects.get(
            course=self.alt_course, title='Sample Course Assignment')
        self.assertEquals(len(project1.citations()), 5)
Ejemplo n.º 11
0
    def test_migrate_asset(self):
        data = {'fromCourse': self.sample_course.id,
                'asset_ids[]': [self.asset1.id],
                'project_ids[]': []}

        # Migrate assets from SampleCourse into Alternate Course
        # test_instructor_three is a member of both courses
        request = RequestFactory().post('/dashboard/migrate/', data)
        request.user = self.instructor_three
        request.course = self.alt_course

        view = MigrateCourseView()
        view.request = request
        response = view.post(request)

        the_json = json.loads(response.content)
        self.assertTrue(the_json['success'])
        self.assertEquals(the_json['asset_count'], 1)
        self.assertEquals(the_json['project_count'], 0)
        self.assertEquals(the_json['note_count'], 3)

        new_asset = Asset.objects.get(course=self.alt_course,
                                      title=self.asset1.title)
        self.assertEquals(new_asset.sherdnote_set.count(), 2)

        # verify there is a global annotation for instructor three
        ga = new_asset.global_annotation(self.instructor_three, False)
        self.assertIsNone(ga.title)
        self.assertEquals(ga.tags, '')
        self.assertIsNone(ga.body)

        # verify there is a selection annotation for instructor three
        note = new_asset.sherdnote_set.get(title=self.instructor_note.title)
        self.assertEquals(note.tags, '')
        self.assertIsNone(note.body)
        self.assertFalse(note.is_global_annotation())