def test_get_themes(self): """ Tests template paths are returned from enabled theme. """ expected_themes = [ Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme')), Theme('red-theme', 'red-theme', get_theme_base_dir('red-theme')), Theme('edge.edx.org', 'edge.edx.org', get_theme_base_dir('edge.edx.org')), Theme('edx.org', 'edx.org', get_theme_base_dir('edx.org')), Theme('stanford-style', 'stanford-style', get_theme_base_dir('stanford-style')), ] actual_themes = get_themes() self.assertItemsEqual(expected_themes, actual_themes)
def test_get_themes_2(self): """ Tests template paths are returned from enabled theme. """ expected_themes = [ Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT), ] actual_themes = get_themes() self.assertItemsEqual(expected_themes, actual_themes)
def test_path(self, asset): """ Verify storage returns correct file path depending upon the enabled theme """ with patch( "openedx.core.djangoapps.theming.storage.get_current_theme", return_value=Theme(self.enabled_theme, self.enabled_theme, get_theme_base_dir(self.enabled_theme)), ): returned_path = self.storage.path(asset) expected_path = self.themes_dir / self.enabled_theme / "lms/static/" / asset self.assertEqual(expected_path, returned_path)
def test_url(self, asset): """ Verify storage returns correct url depending upon the enabled theme """ with patch( "openedx.core.djangoapps.theming.storage.get_current_theme", return_value=Theme(self.enabled_theme, self.enabled_theme, get_theme_base_dir(self.enabled_theme)), ): asset_url = self.storage.url(asset) # remove hash key from file url asset_url = re.sub(r"(\.\w+)(\.png|\.ico)$", r"\g<2>", asset_url) expected_url = self.storage.base_url + self.enabled_theme + "/" + asset self.assertEqual(asset_url, expected_url)
def test_get_themes(self): """ Tests template paths are returned from enabled theme. """ expected_themes = [ Theme('dark-theme', 'dark-theme', get_theme_base_dir('dark-theme'), settings.PROJECT_ROOT), Theme('edge.edx.org', 'edge.edx.org', get_theme_base_dir('edge.edx.org'), settings.PROJECT_ROOT), Theme('edx.org', 'edx.org', get_theme_base_dir('edx.org'), settings.PROJECT_ROOT), Theme('open-edx', 'open-edx', get_theme_base_dir('open-edx'), settings.PROJECT_ROOT), Theme('red-theme', 'red-theme', get_theme_base_dir('red-theme'), settings.PROJECT_ROOT), Theme('stanford-style', 'stanford-style', get_theme_base_dir('stanford-style'), settings.PROJECT_ROOT), Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT), ] actual_themes = get_themes() six.assertCountEqual(self, expected_themes, actual_themes)