chore: resolve conflicts

This commit is contained in:
salman2013
2023-10-23 12:05:25 +05:00
391 changed files with 6442 additions and 7220 deletions

View File

@@ -18,6 +18,7 @@ from django.test import override_settings
from six import unichr
from six.moves import range
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.capa.safe_exec import safe_exec, update_hash
from xmodule.capa.safe_exec.remote_exec import is_codejail_rest_service_enabled
@@ -81,17 +82,30 @@ class TestSafeExec(unittest.TestCase): # lint-amnesty, pylint: disable=missing-
class TestSafeOrNot(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
@skip_unless_lms
def test_cant_do_something_forbidden(self):
'''
Demonstrates that running unsafe code inside the code jail
throws SafeExecException, protecting the calling process.
This test generally is skipped in CI due to its complex setup. That said, we recommend that devs who are
hacking on CodeJail or advanced CAPA in any significant way take the time to make sure it passes locally.
See either:
* in-platform setup: https://github.com/openedx/edx-platform/blob/master/xmodule/capa/safe_exec/README.rst
* remote setup (using Tutor): https://github.com/eduNEXT/tutor-contrib-codejail
Note on @skip_unless_lms:
This test can also be run in a CMS context, but that's giving us trouble in CI right now (the skip logic isn't
working). So, if you're running this locally, feel free to remove @skip_unless_lms and run it against CMS too.
'''
# Can't test for forbiddenness if CodeJail isn't configured for python.
# If in-platform codejail isn't configured...
if not jail_code.is_configured("python"):
# Can't test for forbiddenness if CodeJail rest service isn't enabled.
# Remote codejailservice must be running, see https://github.com/eduNEXT/tutor-contrib-codejail/
# ...AND if remote codejail isn't configured...
if not is_codejail_rest_service_enabled():
# ...then skip this test.
pytest.skip(reason="Local or remote codejail has to be configured and enabled to run this test.")
g = {}

View File

@@ -8,9 +8,11 @@ from django.test.utils import override_settings
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from xblock.fields import ScopeIds
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.capa.xqueue_interface import XQueueInterface, XQueueService
@skip_unless_lms
class XQueueServiceTest(TestCase):
"""Test the XQueue service methods."""
def setUp(self):

View File

@@ -504,6 +504,11 @@ class ProblemBlock(
ProblemBlock.markdown,
ProblemBlock.use_latex_compiler,
ProblemBlock.show_correctness,
# Temporarily remove the ability to see MATLAB API key in Studio, as
# a pre-cursor to removing it altogether.
# https://github.com/openedx/public-engineering/issues/192
ProblemBlock.matlab_api_key,
])
return non_editable_fields

View File

@@ -619,14 +619,6 @@ class CourseFields: # lint-amnesty, pylint: disable=missing-class-docstring
# Ensure that courses imported from XML keep their image
default="images_course_image.jpg"
)
issue_badges = Boolean(
display_name=_("Issue Open Badges"),
help=_(
"Issue Open Badges badges for this course. Badges are generated when certificates are created."
),
scope=Scope.settings,
default=True
)
## Course level Certificate Name overrides.
cert_name_short = String(
help=_(

View File

@@ -12,8 +12,8 @@ from web_fragments.fragment import Fragment
from xblock.completable import XBlockCompletionMode
from xblock.core import XBlock
from xblock.fields import UNIQUE_ID, Scope, String
from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin
from xblock.utils.resources import ResourceLoader
from xblock.utils.studio_editable import StudioEditableXBlockMixin
from lms.djangoapps.discussion.django_comment_client.permissions import has_permission
from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration, Provider

View File

@@ -369,7 +369,7 @@ class ModuleStoreTestUsersMixin():
"""
A mixin to help manage test users.
"""
TEST_PASSWORD = 'test'
TEST_PASSWORD = 'Password1234'
def create_user_for_course(self, course, user_type=CourseUserType.ENROLLED):
"""

View File

@@ -29,6 +29,7 @@ from xblock.fields import ScopeIds
from xblock.scorable import Score
import xmodule
from openedx.core.djangolib.testing.utils import skip_unless_lms
from xmodule.capa import responsetypes
from xmodule.capa.correctmap import CorrectMap
from xmodule.capa.responsetypes import LoncapaProblemError, ResponseError, StudentInputError
@@ -182,6 +183,7 @@ if submission[0] == '':
@ddt.ddt
@skip_unless_lms
class ProblemBlockTest(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
def setUp(self):
@@ -2898,6 +2900,7 @@ class ComplexEncoderTest(unittest.TestCase): # lint-amnesty, pylint: disable=mi
# ignore quotes
@skip_unless_lms
class ProblemCheckTrackingTest(unittest.TestCase):
"""
Ensure correct tracking information is included in events emitted during problem checks.

View File

@@ -1,9 +1,10 @@
"""
Tests for library tools service.
Tests for library tools service (only used by CMS)
"""
from unittest.mock import patch
from opaque_keys.edx.keys import UsageKey
from openedx.core.djangolib.testing.utils import skip_unless_cms
from openedx.core.djangoapps.content_libraries import api as library_api
from openedx.core.djangoapps.content_libraries.tests.base import ContentLibrariesRestApiTest
from openedx.core.djangoapps.xblock.api import load_block
@@ -13,6 +14,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, LibraryFactory
from xmodule.modulestore.tests.utils import MixedSplitTestCase
@skip_unless_cms
class LibraryToolsServiceTest(MixedSplitTestCase):
"""
Tests for library service.
@@ -40,6 +42,7 @@ class LibraryToolsServiceTest(MixedSplitTestCase):
assert mock_get_library_summaries.called
@skip_unless_cms
class ContentLibraryToolsTest(MixedSplitTestCase, ContentLibrariesRestApiTest):
"""
Tests for LibraryToolsService which interact with blockstore-based content libraries
@@ -63,16 +66,16 @@ class ContentLibraryToolsTest(MixedSplitTestCase, ContentLibrariesRestApiTest):
course = CourseFactory.create(modulestore=self.store, user_id=self.user.id)
CourseInstructorRole(course.id).add_users(self.user)
# Add Source from library block to the course
sourced_block = self.make_block("library_sourced", course, user_id=self.user.id)
lc_block = self.make_block("library_content", course, user_id=self.user.id)
# Import the unit block from the library to the course
self.tools.import_from_blockstore(sourced_block, [unit_block_id])
self.tools.import_from_blockstore(lc_block, [unit_block_id])
# Verify imported block with its children
assert len(sourced_block.children) == 1
assert sourced_block.children[0].category == 'unit'
assert len(lc_block.children) == 1
assert lc_block.children[0].category == 'unit'
imported_unit_block = self.store.get_item(sourced_block.children[0])
imported_unit_block = self.store.get_item(lc_block.children[0])
assert len(imported_unit_block.children) == 1
assert imported_unit_block.children[0].category == 'html'
@@ -86,10 +89,10 @@ class ContentLibraryToolsTest(MixedSplitTestCase, ContentLibrariesRestApiTest):
# Check that reimporting updates the target block
self._set_library_block_olx(html_block_id, '<html><a href="/static/test.txt">Foo bar</a></html>')
self.tools.import_from_blockstore(sourced_block, [unit_block_id])
self.tools.import_from_blockstore(lc_block, [unit_block_id])
assert len(sourced_block.children) == 1
imported_unit_block = self.store.get_item(sourced_block.children[0])
assert len(lc_block.children) == 1
imported_unit_block = self.store.get_item(lc_block.children[0])
assert len(imported_unit_block.children) == 1
imported_html_block = self.store.get_item(imported_unit_block.children[0])
assert 'Hello world' not in imported_html_block.data