refactor: move xmodule folder to root
- Moving xmodule folder to root as we're dissolving sub-projects of common folder in edx-platform
- More info: https://openedx.atlassian.net/browse/BOM-2579
- -e common/lib/xmodule has been removed from the requirements as xmodule has itself become the part of edx-platform and not being installed through requirements
- The test files common/lib/xmodule/test_files/ have been removed as they are not being used anymore
This commit is contained in:
56
xmodule/tests/test_import_static.py
Normal file
56
xmodule/tests/test_import_static.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
Tests that check that we ignore the appropriate files when importing courses.
|
||||
"""
|
||||
|
||||
|
||||
import unittest
|
||||
from unittest.mock import Mock
|
||||
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
|
||||
from xmodule.modulestore.tests.utils import (
|
||||
DOT_FILES_DICT,
|
||||
TILDA_FILES_DICT,
|
||||
add_temp_files_from_dict,
|
||||
remove_temp_files_from_list
|
||||
)
|
||||
from xmodule.modulestore.xml_importer import StaticContentImporter
|
||||
from xmodule.tests import DATA_DIR
|
||||
|
||||
|
||||
class IgnoredFilesTestCase(unittest.TestCase):
|
||||
"""
|
||||
Tests for ignored files
|
||||
"""
|
||||
course_dir = DATA_DIR / "course_ignore"
|
||||
dict_list = [DOT_FILES_DICT, TILDA_FILES_DICT]
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
for dictionary in self.dict_list:
|
||||
self.addCleanup(remove_temp_files_from_list, list(dictionary.keys()), self.course_dir / "static")
|
||||
add_temp_files_from_dict(dictionary, self.course_dir / "static")
|
||||
|
||||
def test_sample_static_files(self):
|
||||
"""
|
||||
Test for to ensure Mac OS metadata files (filename starts with "._") as well
|
||||
as files ending with "~" get ignored, while files starting with "." are not.
|
||||
"""
|
||||
course_id = CourseLocator("edX", "course_ignore", "2014_Fall")
|
||||
content_store = Mock()
|
||||
content_store.generate_thumbnail.return_value = ("content", "location")
|
||||
static_content_importer = StaticContentImporter(
|
||||
static_content_store=content_store,
|
||||
course_data_path=self.course_dir,
|
||||
target_id=course_id
|
||||
)
|
||||
static_content_importer.import_static_content_directory()
|
||||
saved_static_content = [call[0][0] for call in content_store.save.call_args_list]
|
||||
name_val = {sc.name: sc.data for sc in saved_static_content}
|
||||
assert 'example.txt' in name_val
|
||||
assert '.example.txt' in name_val
|
||||
assert b'GREEN' in name_val['example.txt']
|
||||
assert b'BLUE' in name_val['.example.txt']
|
||||
assert '._example.txt' not in name_val
|
||||
assert '.DS_Store' not in name_val
|
||||
assert 'example.txt~' not in name_val
|
||||
Reference in New Issue
Block a user