コード例 #1
0
    def test_group_invite(self):
        """Tests group nitpicky invitation behavior"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin).put().get()
        assignment = make_fake_assignment(course, admin).put().get()
        group = make_fake_group(assignment, admin, student).put().get()

        self.assertIn('is not a valid user', group.invite('*****@*****.**'))
        self.assertIn('is not enrolled in', group.invite(student.email[0]))

        group.invited = [student.key]
        models.Participant.add_role(student.key, course.key,
                                    constants.STUDENT_ROLE)
        self.assertIn('has already been invited',
                      group.invite(student.email[0]))

        group.invited = []
        self.assertIn('is already in the group',
                      group.invite(student.email[0]))

        assignment.max_group_size = 2
        assignment.put()
        student2 = models.User(email=['*****@*****.**']).put().get()
        models.Participant.add_role(student2.key, course.key,
                                    constants.STUDENT_ROLE)
        self.assertEqual(2, group.assignment.get().max_group_size)
        self.assertEqual(2, len(group.member))
        self.assertEqual('The group is full', group.invite(student2.email[0]))
コード例 #2
0
ファイル: test_models.py プロジェクト: jvperrin/ok
 def test_group_lookup_or_create(self):
     """TEsts that group lookup_or_create works"""
     admin = models.User(email=['*****@*****.**']).put().get()
     student = models.User(email=['*****@*****.**']).put().get()
     course = make_fake_course(admin)
     assignment = make_fake_assignment(course, admin).put().get()
     models.Group._lookup_or_create(student.key, assignment.key)
コード例 #3
0
 def test_group_lookup_or_create(self):
     """TEsts that group lookup_or_create works"""
     admin = models.User(email=['*****@*****.**']).put().get()
     student = models.User(email=['*****@*****.**']).put().get()
     course = make_fake_course(admin)
     assignment = make_fake_assignment(course, admin).put().get()
     models.Group._lookup_or_create(student.key, assignment.key)
コード例 #4
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_get_final_w_revision(self):
        """"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        assignment = make_fake_assignment(course, admin)
        assignment.revision = True
        assignment.put().get()

        backup = models.Backup(
            submitter=student.key, assignment=assignment.key).put()
        revision = models.Backup(
            submitter=student.key, assignment=assignment.key).put()
        submission = models.Submission(backup=backup).put()
        revision = models.Submission(backup=backup).put()
        models.FinalSubmission(
            submitter=student.key,
            assignment=assignment.key,
            group=make_fake_group(assignment, admin, student).key,
            submission=submission).put().get()

        self.assertEqual(revision.get().mark_as_final().get().revision,
                         revision)
        # Make sure the original submission is retained.
        self.assertEqual(revision.get().mark_as_final().get().submission,
                         submission)
コード例 #5
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_group_invite(self):
        """Tests group nitpicky invitation behavior"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin).put().get()
        assignment = make_fake_assignment(course, admin).put().get()
        group = make_fake_group(assignment, admin, student).put().get()

        self.assertIn('is not a valid user', group.invite('*****@*****.**'))
        self.assertIn('is not enrolled in', group.invite(student.email[0]))

        group.invited = [student.key]
        models.Participant.add_role(student.key, course.key, constants.STUDENT_ROLE)
        self.assertIn('has already been invited', group.invite(student.email[0]))

        group.invited = []
        self.assertIn('is already in the group', group.invite(student.email[0]))

        assignment.max_group_size = 2
        assignment.put()
        student2 = models.User(email=['*****@*****.**']).put().get()
        models.Participant.add_role(student2.key, course.key, constants.STUDENT_ROLE)
        self.assertEqual(2, group.assignment.get().max_group_size)
        self.assertEqual(2, len(group.member))
        self.assertEqual('The group is full', group.invite(student2.email[0]))
コード例 #6
0
 def test_group_lookup_by_assignment(self):
     """Test lookup by assignment"""
     admin = models.User(email=['*****@*****.**']).put().get()
     student = models.User(email=['*****@*****.**']).put().get()
     course = make_fake_course(admin)
     assignment = make_fake_assignment(course, admin).put().get()
     group = make_fake_group(assignment, admin, student).put()
     groups = models.Group.lookup_by_assignment(assignment)
     self.assertIn(group, [g.key for g in groups])
コード例 #7
0
ファイル: test_models.py プロジェクト: jvperrin/ok
 def test_group_lookup_by_assignment(self):
     """Test lookup by assignment"""
     admin = models.User(email=['*****@*****.**']).put().get()
     student = models.User(email=['*****@*****.**']).put().get()
     course = make_fake_course(admin)
     assignment = make_fake_assignment(course, admin).put().get()
     group = make_fake_group(assignment, admin, student).put()
     groups = models.Group.lookup_by_assignment(assignment)
     self.assertIn(group, [g.key for g in groups])
コード例 #8
0
	def setUp(self):
		super(GroupAPITest, self).setUp()
		self.course = make_fake_course(self.user)
		self.course.put()
		self.assignment = make_fake_assignment(self.course, self.user)
		self.assignment.put()
		for student_name in [a for a in self.accounts if 'student' in a]:
			s = self.accounts[student_name]
			models.Participant.add_role(s, self.course, constants.STUDENT_ROLE)
コード例 #9
0
ファイル: test_api_group.py プロジェクト: jackzhao-mj/ok
 def setUp(self):
   super(GroupAPITest, self).setUp()
   self.course = make_fake_course(self.user)
   self.course.put()
   self.assignment = make_fake_assignment(self.course, self.user)
   self.assignment.put()
   for student_name in [a for a in self.accounts if 'student' in a]:
     s = self.accounts[student_name]
     models.Participant.add_role(s, self.course, constants.STUDENT_ROLE)
コード例 #10
0
    def setUp(self):
        BaseTestCase.setUp(self)
        self._caught_exception = None
        self.user = self.get_basic_user()
        self.admin = models.User(email=['*****@*****.**'], is_admin=True)
        self.admin.put()

        self.course = make_fake_course(self.admin)
        self.course.put()
        self.assign = make_fake_assignment(self.course, self.admin)
        self.assign.put()
コード例 #11
0
ファイル: test_user.py プロジェクト: jackzhao-mj/ok
    def setUp(self):
        BaseTestCase.setUp(self)
        self._caught_exception = None
        self.user = self.get_basic_user()
        self.admin = models.User(email=['*****@*****.**'], is_admin=True)
        self.admin.put()

        self.course = make_fake_course(self.admin)
        self.course.put()
        self.assign = make_fake_assignment(self.course, self.admin)
        self.assign.put()
コード例 #12
0
    def get_basic_instance(self, mutate=True):
        name = 'proj'
        if mutate:
            name += str(self.num)
            self.num += 1

        self._course = make_fake_course(self.user)
        self._course.put()
        self.enroll_accounts(self._course)
        self._assignment = make_fake_assignment(self._course, self.user)
        self._assignment.name = name
        return self._assignment
コード例 #13
0
ファイル: test_api.py プロジェクト: yuecong/ok
    def get_basic_instance(self, mutate=True):
        name = 'proj'
        if mutate:
            name += str(self.num)
            self.num += 1

        self._course = make_fake_course(self.user)
        self._course.put()
        self.enroll_accounts(self._course)
        self._assignment = make_fake_assignment(self._course, self.user)
        self._assignment.name = name
        return self._assignment
コード例 #14
0
ファイル: test_api_search.py プロジェクト: jvperrin/ok
	def setUp(self):
		super(SearchAPITest, self).setUp()
		self.assignment_name = 'Hog Project'
		self.user = self.accounts['dummy_student2']
		self._course = make_fake_course(self.user)
		self._course.put()
		self._assign = make_fake_assignment(self._course, self.user)
		self._assign.name = self._assign.display_name = self.assignment_name
		self._assign.put()
		self._backup = make_fake_backup(self._assign, self.user)
		self._submission = make_fake_submission(self._backup)
		self._finalsubmission = make_fake_finalsubmission(self._submission, self._assign, self.user)
コード例 #15
0
 def setUp(self):
     super(SearchAPITest, self).setUp()
     self.assignment_name = 'Hog Project'
     self.user = self.accounts['dummy_student2']
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._backup = make_fake_backup(self._assign, self.user)
     self._submission = make_fake_submission(self._backup)
     self._finalsubmission = make_fake_finalsubmission(
         self._submission, self._assign, self.user)
コード例 #16
0
ファイル: test_api_queue.py プロジェクト: gitmagic-bot/ok
 def setUp(self):
     super(QueueAPITest, self).setUp()
     self.user = self.accounts['dummy_admin']
     self.staff = self.accounts['dummy_staff']
     self.user1 = self.accounts['dummy_student']
     self.user2 = self.accounts['dummy_student2']
     self.user3 = self.accounts['dummy_student3']
     self.assignment_name = 'Hog Project'
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
コード例 #17
0
ファイル: test_autoupdate.py プロジェクト: gitmagic-bot/ok
    def setUp(self):
        super(AutoUpdateTest, self).setUp()
        due_date = datetime.datetime.now() + datetime.timedelta(days=2)
        self.user = models.User.get_or_insert('*****@*****.**')

        self.course = make_fake_course(self.user)
        self.course.put()

        self.assignment = make_fake_assignment(self.course, self.user)
        self.assignment.put()

        self.version = models.Version.get_or_insert('ok', base_url="https://www.baseurl.com")
        self.invalid = False
コード例 #18
0
ファイル: test_api_backup.py プロジェクト: gitmagic-bot/ok
	def setUp(self):
		super(BackupAPITest, self).setUp()
		self.assignment_name = u'test assignment'
		self._course = make_fake_course(self.user)
		self._course.put()
		self._assign = make_fake_assignment(self._course, self.user)
		self._assign.name = self.assignment_name
		self._assign.put()

		self._submitter = self.accounts['dummy_student']
		self._submitter.put()
		self.logout()
		self.login('dummy_student')
コード例 #19
0
ファイル: test_api_backup.py プロジェクト: jackzhao-mj/ok
    def setUp(self):
        super(BackupAPITest, self).setUp()
        self.assignment_name = u'test assignment'
        self._course = make_fake_course(self.user)
        self._course.put()
        self._assign = make_fake_assignment(self._course, self.user)
        self._assign.name = self.assignment_name
        self._assign.put()

        self._submitter = self.accounts['dummy_student']
        self._submitter.put()
        self.logout()
        self.login('dummy_student')
コード例 #20
0
 def setUp(self):
     super(UtilsTestCase, self).setUp()
     self.user = self.accounts['dummy_admin']
     self.user1 = self.accounts['dummy_student']
     self.user2 = self.accounts['dummy_student2']
     self.user3 = self.accounts['dummy_student3']
     self.assignment_name = 'Hog Project'
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
コード例 #21
0
    def test_backup_index(self):
        """Tests permissions for backup"""
        admin = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        models.Participant.add_role(admin.key, course.key,
                                    constants.STAFF_ROLE)

        index = Need('index')
        assignment = make_fake_assignment(course, admin)
        backup = models.Backup(submitter=admin.key,
                               assignment=assignment.key).put().get()
        query = models.Backup.query()
        self.assertNotEqual(False,
                            models.Backup._can(admin, index, backup, query))
コード例 #22
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_backup_index(self):
        """Tests permissions for backup"""
        admin = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        models.Participant.add_role(
            admin.key, course.key, constants.STAFF_ROLE)

        index = Need('index')
        assignment = make_fake_assignment(course, admin)
        backup = models.Backup(
            submitter=admin.key, assignment=assignment.key).put().get()
        query = models.Backup.query()
        self.assertNotEqual(
            False, models.Backup._can(admin, index, backup, query))
コード例 #23
0
ファイル: test_api_course.py プロジェクト: jvperrin/ok
 def setUp(self):
     super(CourseAPITest, self).setUp()
     self.user = self.accounts["dummy_admin"]
     self.user1 = self.accounts["dummy_student"]
     self.user2 = self.accounts["dummy_student2"]
     self.user3 = self.accounts["dummy_student3"]
     self.assignment_name = "Hog Project"
     self._course = self.get_basic_instance()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
     self._version = self.get_basic_instance()
コード例 #24
0
ファイル: test_utils.py プロジェクト: gitmagic-bot/ok
	def setUp(self):
		super(UtilsTestCase, self).setUp()
		self.user = self.accounts['dummy_admin']
		self.user1 = self.accounts['dummy_student']
		self.user2 = self.accounts['dummy_student2']
		self.user3 = self.accounts['dummy_student3']
		self.assignment_name = 'Hog Project'
		self._course = make_fake_course(self.user)
		self._course.put()
		self._assign = make_fake_assignment(self._course, self.user)
		self._assign.name = self._assign.display_name = self.assignment_name
		self._assign.put()
		self._backup = make_fake_backup(self._assign, self.user2)
		self._submission = make_fake_submission(self._backup)
コード例 #25
0
ファイル: test_autoupdate.py プロジェクト: jackzhao-mj/ok
    def setUp(self):
        super(AutoUpdateTest, self).setUp()
        due_date = datetime.datetime.now() + datetime.timedelta(days=2)
        self.user = models.User.get_or_insert('*****@*****.**')

        self.course = make_fake_course(self.user)
        self.course.put()

        self.assignment = make_fake_assignment(self.course, self.user)
        self.assignment.put()

        self.version = models.Version.get_or_insert(
            'ok', base_url="https://www.baseurl.com")
        self.invalid = False
コード例 #26
0
ファイル: test_api_analytics.py プロジェクト: jvperrin/ok
 def setUp(self):
     super(AnalyticsAPITest, self).setUp()
     self.user = self.accounts["dummy_admin"]
     self.user1 = self.accounts["dummy_student"]
     self.user2 = self.accounts["dummy_student2"]
     self.user3 = self.accounts["dummy_student3"]
     self.assignment_name = "Hog Project"
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
     self._finalsubmission = make_fake_finalsubmission(self._submission, self._assign, self.user2)
コード例 #27
0
    def test_get_final(self):
        """Test get_final"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        assignment = make_fake_assignment(course, admin).put().get()

        backup = models.Backup(submitter=student.key,
                               assignment=assignment.key).put()
        submission = models.Submission(backup=backup).put()
        fsubm = models.FinalSubmission(submitter=student.key,
                                       assignment=assignment.key,
                                       group=make_fake_group(
                                           assignment, admin, student).key,
                                       submission=submission).put().get()
        self.assertEqual(fsubm, submission.get().get_final())
コード例 #28
0
    def test_get_final_wo_final(self):
        """"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        assignment = make_fake_assignment(course, admin)
        assignment.revision = True
        assignment.put().get()

        group = make_fake_group(assignment, admin, student).put()

        backup = models.Backup(submitter=student.key,
                               assignment=assignment.key).put()
        submission = models.Submission(backup=backup).put()

        self.assertEqual(submission.get().mark_as_final().get().group, group)
コード例 #29
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_get_final(self):
        """Test get_final"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        assignment = make_fake_assignment(course, admin).put().get()

        backup = models.Backup(
            submitter=student.key, assignment=assignment.key).put()
        submission = models.Submission(backup=backup).put()
        fsubm = models.FinalSubmission(
            submitter=student.key,
            assignment=assignment.key,
            group=make_fake_group(assignment, admin, student).key,
            submission=submission).put().get()
        self.assertEqual(fsubm, submission.get().get_final())
コード例 #30
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_get_final_wo_final(self):
        """"""
        admin = models.User(email=['*****@*****.**']).put().get()
        student = models.User(email=['*****@*****.**']).put().get()
        course = make_fake_course(admin)
        assignment = make_fake_assignment(course, admin)
        assignment.revision = True
        assignment.put().get()

        group = make_fake_group(assignment, admin, student).put()

        backup = models.Backup(
            submitter=student.key, assignment=assignment.key).put()
        submission = models.Submission(backup=backup).put()

        self.assertEqual(submission.get().mark_as_final().get().group,
                         group)
コード例 #31
0
ファイル: test_api_assignment.py プロジェクト: jvperrin/ok
 def setUp(self):
     super(AssignmentAPITest, self).setUp()
     self.user = self.accounts["dummy_admin"]
     self.user1 = self.accounts["dummy_student"]
     self.user2 = self.accounts["dummy_student2"]
     self.user3 = self.accounts["dummy_student3"]
     self.assignment_name = "Hog Project"
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.autograding_enabled = True
     self._assign.autograding_key = "NotReallyAnAutograderKey"
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._group = make_fake_group(self._assign, self.user1, self.user2)
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
     self._finalsubmission = make_fake_finalsubmission(self._submission, self._assign, self.user2)
コード例 #32
0
	def setUp(self):
		super(SubmissionAPITest, self).setUp()
		self.user = self.accounts['dummy_admin']
		self.user1 = self.accounts['dummy_student']
		self.user2 = self.accounts['dummy_student2']
		self.user3 = self.accounts['dummy_student3']
		self.assignment_name = 'Hog Project'
		self._course = make_fake_course(self.user)
		self._course.put()
		self._assign = make_fake_assignment(self._course, self.user)
		self._assign.name = self._assign.display_name = self.assignment_name
		self._assign.put()
		self._backup = make_fake_backup(self._assign, self.user2)
		self._submission = make_fake_submission(self._backup)
		self._finalsubmission = make_fake_finalsubmission(self._submission, self._assign, self.user2)
		self._score = models.Score(score=2).put()
		self._submission.score = [self._score.get()]
		self._submission.put()
コード例 #33
0
ファイル: test_api_submission.py プロジェクト: jvperrin/ok
 def setUp(self):
     super(SubmissionAPITest, self).setUp()
     self.user = self.accounts["dummy_admin"]
     self.user1 = self.accounts["dummy_student"]
     self.user2 = self.accounts["dummy_student2"]
     self.user3 = self.accounts["dummy_student3"]
     self.assignment_name = "Hog Project"
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
     self._finalsubmission = make_fake_finalsubmission(self._submission, self._assign, self.user2)
     self._score = models.Score(score=2, tag="composition").put()
     self._submission.score = [self._score.get()]
     self._submission.put()
コード例 #34
0
 def setUp(self):
     super(AssignmentAPITest, self).setUp()
     self.user = self.accounts['dummy_admin']
     self.user1 = self.accounts['dummy_student']
     self.user2 = self.accounts['dummy_student2']
     self.user3 = self.accounts['dummy_student3']
     self.assignment_name = 'Hog Project'
     self._course = make_fake_course(self.user)
     self._course.put()
     self._assign = make_fake_assignment(self._course, self.user)
     self._assign.autograding_enabled = True
     self._assign.name = self._assign.display_name = self.assignment_name
     self._assign.put()
     self._group = make_fake_group(self._assign, self.user1, self.user2)
     self._backup = make_fake_backup(self._assign, self.user2)
     self._submission = make_fake_submission(self._backup)
     self._finalsubmission = make_fake_finalsubmission(
         self._submission, self._assign, self.user2)
コード例 #35
0
    def test_assignment_comparator(self):
        """Tests that assignments can be compared like numbers... by due date"""
        creator_key = models.User(email=['*****@*****.**']).put()
        course = make_fake_course(creator_key.get())
        assignment1 = make_fake_assignment(course, creator_key.get())
        assignment2 = models.Assignment(name='hw1',
                                        points=3,
                                        display_name="CS 61A",
                                        templates="[]",
                                        course=course.key,
                                        creator=creator_key,
                                        max_group_size=4,
                                        due_date=datetime.datetime.now() +
                                        datetime.timedelta(days=3))
        self.assertTrue(assignment2 < assignment1)
        self.assertFalse(assignment1 < assignment2)

        lst = [assignment1, assignment2]
        lst = sorted(lst)
        self.assertEqual(lst, [assignment2, assignment1])
コード例 #36
0
ファイル: test_models.py プロジェクト: jvperrin/ok
    def test_assignment_comparator(self):
        """Tests that assignments can be compared like numbers... by due date"""
        creator_key = models.User(email=['*****@*****.**']).put()
        course = make_fake_course(creator_key.get())
        assignment1 = make_fake_assignment(course, creator_key.get())
        assignment2 = models.Assignment(
            name='hw1',
            points=3,
            display_name="CS 61A",
            templates="[]",
            course=course.key,
            creator=creator_key,
            max_group_size=4,
            due_date=datetime.datetime.now() + datetime.timedelta(days=3))
        self.assertTrue(assignment2 < assignment1)
        self.assertFalse(assignment1 < assignment2)

        lst = [assignment1, assignment2]
        lst = sorted(lst)
        self.assertEqual(lst, [assignment2, assignment1])