Пример #1
0
 def test_check_if_email_has_been_sent_to_user(self):
     suggestion_services.create_new_user_contribution_scoring_model(
         self.user_a_id, 'category_a', 15)
     self.assertFalse(
         suggestion_services.check_if_email_has_been_sent_to_user(
             self.user_a_id, 'category_a'))
     suggestion_services.mark_email_has_been_sent_to_user(
         self.user_a_id, 'category_a')
     self.assertTrue(
         suggestion_services.check_if_email_has_been_sent_to_user(
             self.user_a_id, 'category_a'))
Пример #2
0
    def test_get_suggestions_to_review_list(self):
        self.login(self.OWNER_EMAIL)

        suggestions = self.get_json(
            feconf.CREATOR_DASHBOARD_DATA_URL)['suggestions_to_review_list']
        self.assertEqual(suggestions, [])

        change_dict = {
            'cmd': 'edit_state_property',
            'property_name': 'content',
            'state_name': 'Introduction',
            'new_value': ''
        }
        self.save_new_default_exploration('exp1', self.owner_id)

        suggestion_services.create_new_user_contribution_scoring_model(
            self.owner_id, 'category1', 15)
        model1 = feedback_models.GeneralFeedbackThreadModel.create(
            'exploration.exp1.thread_1')
        model1.entity_type = 'exploration'
        model1.entity_id = 'exp1'
        model1.subject = 'subject'
        model1.put()

        suggestion_models.GeneralSuggestionModel.create(
            suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
            suggestion_models.TARGET_TYPE_EXPLORATION,
            'exp1', 1, suggestion_models.STATUS_IN_REVIEW, self.owner_id_1,
            self.owner_id_2, change_dict, 'category1',
            'exploration.exp1.thread_1')

        change_dict['old_value'] = {
            'content_id': 'content',
            'html': ''
        }
        suggestions = self.get_json(
            feconf.CREATOR_DASHBOARD_DATA_URL)['suggestions_to_review_list']

        self.assertEqual(len(suggestions), 1)
        self.assertEqual(suggestions[0]['change'], change_dict)
        # Test to check if suggestions populate old value of the change.
        self.assertEqual(
            suggestions[0]['change']['old_value']['content_id'], 'content')

        self.logout()
Пример #3
0
 def setUp(self):
     super(UserContributionScoringUnitTests, self).setUp()
     suggestion_services.create_new_user_contribution_scoring_model(
         'user1', 'category1', 0)
     suggestion_services.create_new_user_contribution_scoring_model(
         'user1', 'category2', 0)
     suggestion_services.create_new_user_contribution_scoring_model(
         'user2', 'category1', 0)
Пример #4
0
    def setUp(self):
        super(UserContributionScoringUnitTests, self).setUp()
        suggestion_services.create_new_user_contribution_scoring_model(
            'user1', 'category1', 0)
        suggestion_services.create_new_user_contribution_scoring_model(
            'user1', 'category2', 0)
        suggestion_services.create_new_user_contribution_scoring_model(
            'user2', 'category1', 0)

        self.signup('*****@*****.**', 'userA')
        self.signup('*****@*****.**', 'userB')
        self.signup('*****@*****.**', 'userC')
        self.user_a_id = self.get_user_id_from_email('*****@*****.**')
        self.user_b_id = self.get_user_id_from_email('*****@*****.**')
        self.user_c_id = self.get_user_id_from_email('*****@*****.**')
Пример #5
0
    def test_get_next_user_in_rotation(self):
        suggestion_services.create_new_user_contribution_scoring_model(
            self.user_a_id, 'category_a', 15)
        suggestion_services.create_new_user_contribution_scoring_model(
            self.user_b_id, 'category_a', 15)
        suggestion_services.create_new_user_contribution_scoring_model(
            self.user_c_id, 'category_a', 15)

        user_ids = [self.user_a_id, self.user_b_id, self.user_c_id]
        user_ids.sort()
        self.assertEqual(
            suggestion_services.get_next_user_in_rotation('category_a'),
            user_ids[0])
        self.assertEqual(
            suggestion_models.ReviewerRotationTrackingModel.get_by_id(
                'category_a').current_position_in_rotation, user_ids[0])

        self.assertEqual(
            suggestion_services.get_next_user_in_rotation('category_a'),
            user_ids[1])
        self.assertEqual(
            suggestion_models.ReviewerRotationTrackingModel.get_by_id(
                'category_a').current_position_in_rotation, user_ids[1])

        self.assertEqual(
            suggestion_services.get_next_user_in_rotation('category_a'),
            user_ids[2])
        self.assertEqual(
            suggestion_models.ReviewerRotationTrackingModel.get_by_id(
                'category_a').current_position_in_rotation, user_ids[2])

        # Rotates back.
        self.assertEqual(
            suggestion_services.get_next_user_in_rotation('category_a'),
            user_ids[0])
        self.assertEqual(
            suggestion_models.ReviewerRotationTrackingModel.get_by_id(
                'category_a').current_position_in_rotation, user_ids[0])

        self.assertEqual(
            suggestion_services.get_next_user_in_rotation('category_invalid'),
            None)
Пример #6
0
 def test_query_suggestions_that_can_be_reviewed_by_user(self):
     suggestion_services.create_new_user_contribution_scoring_model(
         'user1', 'category1', 15)
     suggestion_services.create_new_user_contribution_scoring_model(
         'user1', 'category2', 15)
     suggestion_services.create_new_user_contribution_scoring_model(
         'user1', 'category3', 5)
     suggestion_models.GeneralSuggestionModel.create(
         suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
         suggestion_models.TARGET_TYPE_EXPLORATION, 'exp1', 1,
         suggestion_models.STATUS_IN_REVIEW, 'author_3', 'reviewer_2',
         self.change, 'category1', 'exploration.exp1.thread_1')
     suggestion_models.GeneralSuggestionModel.create(
         suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
         suggestion_models.TARGET_TYPE_EXPLORATION, 'exp1', 1,
         suggestion_models.STATUS_IN_REVIEW, 'author_3', 'reviewer_2',
         self.change, 'category2', 'exploration.exp1.thread_2')
     suggestion_models.GeneralSuggestionModel.create(
         suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
         suggestion_models.TARGET_TYPE_EXPLORATION, 'exp1', 1,
         suggestion_models.STATUS_IN_REVIEW, 'author_3', 'reviewer_2',
         self.change, 'category3', 'exploration.exp1.thread_3')
     suggestion_models.GeneralSuggestionModel.create(
         suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
         suggestion_models.TARGET_TYPE_EXPLORATION, 'exp1', 1,
         suggestion_models.STATUS_REJECTED, 'author_3', 'reviewer_2',
         self.change, 'category1', 'exploration.exp1.thread_4')
     suggestion_models.GeneralSuggestionModel.create(
         suggestion_models.SUGGESTION_TYPE_EDIT_STATE_CONTENT,
         suggestion_models.TARGET_TYPE_EXPLORATION, 'exp1', 1,
         suggestion_models.STATUS_IN_REVIEW, 'author_3', 'reviewer_2',
         self.change, 'category2', 'exploration.exp1.thread_5')
     self.assertEqual(
         len(
             suggestion_services.
             get_all_suggestions_that_can_be_reviewed_by_user('user1')), 3)
     self.assertEqual(
         len(
             suggestion_services.
             get_all_suggestions_that_can_be_reviewed_by_user('user2')), 0)