def test_content_type_gate_for_block(self):
        ''' Verify that the method returns a content type gate when appropriate '''
        course = self._create_course()
        blocks_dict = course['blocks']
        CourseEnrollmentFactory.create(user=self.user,
                                       course_id=course['course'].id,
                                       mode='audit')
        blocks_dict['graded_1'] = ItemFactory.create(
            parent=blocks_dict['vertical'],
            category='problem',
            graded=True,
            metadata=METADATA,
        )
        blocks_dict['not_graded_1'] = ItemFactory.create(
            parent=blocks_dict['vertical'],
            category='problem',
            graded=False,
            metadata=METADATA,
        )

        # The method returns a content type gate for blocks that should be gated
        self.assertIn(
            'content-paywall',
            ContentTypeGatingService().content_type_gate_for_block(
                self.user, blocks_dict['graded_1'],
                course['course'].id).content)

        # The method returns None for blocks that should not be gated
        self.assertEquals(
            None,
            ContentTypeGatingService().content_type_gate_for_block(
                self.user, blocks_dict['not_graded_1'], course['course'].id))
    def test_check_children_for_content_type_gating_paywall(self, mocked_user):  # pylint: disable=unused-argument
        ''' Verify that the method returns a content type gate when appropriate '''
        course = self._create_course()
        blocks_dict = course['blocks']
        CourseEnrollmentFactory.create(user=self.user,
                                       course_id=course['course'].id,
                                       mode='audit')
        blocks_dict['not_graded_1'] = ItemFactory.create(
            parent=blocks_dict['vertical'],
            category='problem',
            graded=False,
            metadata=METADATA,
        )

        # The method returns a content type gate for blocks that should be gated
        assert ContentTypeGatingService(
        ).check_children_for_content_type_gating_paywall(
            blocks_dict['vertical'], course['course'].id) is None

        blocks_dict['graded_1'] = ItemFactory.create(
            parent=blocks_dict['vertical'],
            category='problem',
            graded=True,
            metadata=METADATA,
        )

        # The method returns None for blocks that should not be gated
        assert 'content-paywall' in ContentTypeGatingService(
        ).check_children_for_content_type_gating_paywall(
            blocks_dict['vertical'], course['course'].id)