Example #1
0
 def test_get_themes(self):
     """
     Tests get_themes returns all themes in themes directory.
     """
     expected_themes = [
         Theme('test-theme', 'test-theme'),
         Theme('test-theme-2', 'test-theme-2'),
     ]
     actual_themes = get_themes()
     self.assertItemsEqual(expected_themes, actual_themes)
Example #2
0
 def test_get_themes(self):
     """
     Tests get_themes returns all themes in themes directory.
     """
     theme_dirs = get_theme_base_dirs()
     expected_themes = [
         Theme('test-theme', 'test-theme', theme_dirs[0]),
         Theme('test-theme-2', 'test-theme-2', theme_dirs[0]),
         Theme('test-theme-3', 'test-theme-3', theme_dirs[1]),
     ]
     actual_themes = get_themes()
     self.assertItemsEqual(expected_themes, actual_themes)
Example #3
0
    def test_path(self):
        """
        Verify storage returns correct file path depending upon the enabled theme
        """
        asset = "images/default-logo.png"
        with patch("ecommerce.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 / "static" / asset

            self.assertEqual(expected_path, returned_path)
Example #4
0
    def test_url(self):
        """
        Verify storage returns correct url depending upon the enabled theme
        """
        asset = "images/default-logo.png"
        with patch("ecommerce.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
            expected_url = self.storage.base_url + self.enabled_theme + "/" + asset

            self.assertEqual(asset_url, expected_url)