def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.discussion_forum
        self.course = MagicMock()

        # student recieiving the message
        self.author = student_factory()
        self.reviewer = student_factory()

        # This would be the content unit
        self.work = fake.text()
        # Set to none so that loader thinks not a quiz
        self.activity_id = self.unit.discussion_forum.id
        self.dao = SqliteDAO()
        self.session = self.dao.session
        self.create_new_and_preexisting_students()
        # Prepare fake work repo to give values to calling  objects

        # self.studentRepo = StudentRepository()
        # self.studentRepo.get_student = MagicMock( return_value=self.reviewer )
        self.contentRepo = ContentRepositoryMock()
        self.contentRepo.get_formatted_work_by = MagicMock(
            return_value=self.work)
        self.review_assign = MagicMock(assessor_id=self.reviewer.id,
                                       assessee_id=self.author.id)
        self.statusRepo = MagicMock()
        # Prepare fake work repo to give values to calling  objects
        self.workRepo = ContentRepositoryMock()
        self.workRepo.create_test_content(self.student_ids)
        self.workRepo.add_students_to_data(self.student_ids,
                                           make_dataframe=True)
    def test_run( self, workLoaderMock, assocRepoMock, messengerMock, studentRepoMock ):
        """Check that each student receives the expected message
        containing the correct student's submission
        """
        students = [ student_factory(), student_factory() ]
        submitter_ids = [ s.student_id for s in students ]
        workRepo = MagicMock()
        workRepo.submitter_ids = submitter_ids
        workLoaderMock.make = MagicMock( return_value=workRepo )

        studentRepoMock.download = MagicMock( return_value=students )
        send = True
        obj = SendReviewToReviewee( course=self.course, unit=self.unit, is_test=True, send=True )
        # ra = ReviewAssociation(assessor_id=students[0], assessee_id=students[1])
        # obj.associationRepo.get_assessor_object = MagicMock(return_value=[ra])

        # call
        obj.run()

        # check
        workLoaderMock.make.assert_called()
        workLoaderMock.make.assert_called_with( self.unit.review, self.course) # only_new=False, rest_timeout=5 )

        obj.studentRepo.download.assert_called()

        obj.messenger.notify.assert_called()
        obj.messenger.notify.assert_called_with( obj.associations, send )
Пример #3
0
    def setUp(self):
        self.config_for_test()
        self.dao = SqliteDAO()
        print("Connected to testing db")
        self.session = self.dao.session

        self.activity_data = activity_data_factory()
        self.target_student = student_factory()
        self.reviewing_student = student_factory()
        self.reviewed_student = student_factory()
        self.activity_id = fake.random.randint(1111, 99999)
Пример #4
0
    def test_run(self, workLoaderMock, assocRepoMock, messengerMock,
                 studentRepoMock, statusRepoMock):
        """Check that each student receives the expected message
        containing the correct student's submission
        """
        students = [student_factory(), student_factory()]

        def student_getter(sid):
            return [s for s in students if s.student_id == sid][0]

        submitter_ids = [s.student_id for s in students]
        workRepo = MagicMock()
        workRepo.submitter_ids = submitter_ids
        workLoaderMock.make = MagicMock(return_value=workRepo)

        studentRepoMock.download = MagicMock(return_value=students)
        studentRepoMock.get_student = student_getter

        obj = SendInitialWorkToReviewer(course=self.course,
                                        unit=self.unit,
                                        is_test=True,
                                        send=True)

        assignments = [
            ReviewAssociation(assessee_id=students[0],
                              assessor_id=students[1]),
            ReviewAssociation(assessee_id=students[1],
                              assessor_id=students[0]),
        ]
        obj.associationRepo.assign_reviewers = MagicMock(
            return_value=assignments)

        # call
        obj.run()

        # check
        workLoaderMock.make.assert_called()
        workLoaderMock.make.assert_called_with(
            self.unit.initial_work,
            self.course)  # only_new=False, rest_timeout=5 )

        obj.studentRepo.download.assert_called()

        obj.associationRepo.assign_reviewers.assert_called()
        obj.associationRepo.assign_reviewers.assert_called_with(submitter_ids)

        obj.messenger.notify.assert_called()
        obj.messenger.notify.assert_called_with(assignments, True)
    def setUp(self):
        self.config_for_test()
        self.dao = SqliteDAO()
        print("Connected to testing db")
        self.session = self.dao.session

        self.student = student_factory()
        self.unit = unit_factory()
        self.activity = fake.random.choice(self.unit.components)

        self.obj = StatusRepository(self.dao, self.activity)
    def test__make_associations_3_submissions( self ):
        # Students only submit once
        # id case
        self.student_ids = [i for i in range(0,3)]
        assoc = self.obj._make_associations(self.student_ids)
        self.assertEqual(3, len(assoc) , "single submission; ids")

        # obj case
        self.students = [student_factory() for i in range(0,3)]
        assoc = self.obj._make_associations(self.students)
        self.assertEqual(3, len(assoc) , "single submission; objects" )
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        # self.activity_data = activity_data_factory()
        self.activity = self.unit.review  #InitialWork( **self.activity_data )

        # student recieiving the message
        self.author = student_factory()
        self.reviewer = student_factory()

        # This would be the content unit
        self.work = fake.text()

        self.studentRepo = StudentRepository()
        self.studentRepo.get_student = MagicMock(return_value=self.reviewer)
        self.contentRepo = ContentRepositoryMock()
        self.contentRepo.get_formatted_work_by = MagicMock(
            return_value=self.work)
        self.review_assign = MagicMock(assessor_id=self.reviewer.id,
                                       assessee_id=self.author.id)
        self.statusRepo = MagicMock()  #create_autospec(StatusRepository)
Пример #8
0
    def setUp( self ):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity = self.unit.metareview

        # student receiving the message
        self.author = student_factory()
        self.reviewer = student_factory()

        # This would be the results of the peer review
        self.work = fake.text()

        self.studentRepo = StudentRepository()
        # self.studentRepo.data = {self.author.id : self.author,
        #                          self.reviewer.id: self.reviewer
        #                          }
        self.studentRepo.get_student = MagicMock( return_value=self.author )
        self.contentRepo = ContentRepositoryMock()
        self.contentRepo.get_formatted_work_by = MagicMock( return_value=self.work )
        self.statusRepo = create_autospec(InvitationStatusRepository)

        self.review_assign = MagicMock( assessor_id=self.reviewer.id, assessee_id=self.author.id )
Пример #9
0
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        # self.activity_data = activity_data_factory()
        self.activity = self.unit.metareview  #InitialWork( **self.activity_data )

        self.author = student_factory()
        # student receiving the message (we are sending the feedback
        # created by the author of the content assignment)
        self.reviewer = student_factory()

        # This would be metareview feedback on the review
        self.work = fake.text()

        self.studentRepo = StudentRepository()
        self.studentRepo.get_student = MagicMock(return_value=self.reviewer)
        self.contentRepo = ContentRepositoryMock()
        self.contentRepo.get_formatted_work_by = MagicMock(
            return_value=self.work)

        self.review_assign = MagicMock(assessor_id=self.reviewer.id,
                                       assessee_id=self.author.id)
        self.statusRepo = create_autospec(FeedbackStatusRepository)
Пример #10
0
    def setUp(self):
        self.config_for_test()
        self.unit = unit_factory()
        self.activity_data = activity_data_factory()
        self.activity = Activity(**self.activity_data)
        # student recieiving the message
        self.receiving_student = student_factory()
        self.reviewed_student_work = fake.text()

        self.studentRepo = StudentRepository()
        self.studentRepo.get_student = MagicMock(
            return_value=self.receiving_student)
        self.contentRepo = ContentRepositoryMock()
        self.statusRepo = create_autospec(StatusRepository)
Пример #11
0
 def test_ensure_student_when_student(self):
     s = student_factory()
     r = ensure_student(s)
     self.assertIsInstance(r, Student, "Returns student")
     self.assertTrue(s == r)