Support Google Font dependencies
Allow downloading fonts from Google Font at install time. Closes GitLab issue #595, thanks to Martin (@efelon) for the report. Closes re-opened GitLab issue #343. Remove included Lato font. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
53
mayan/apps/dependencies/tests/test_classes.py
Normal file
53
mayan/apps/dependencies/tests/test_classes.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
from pathlib2 import Path
|
||||
import shutil
|
||||
|
||||
from mayan.apps.common.tests import BaseTestCase
|
||||
from mayan.apps.storage.utils import mkdtemp
|
||||
|
||||
from ..classes import Dependency, Provider
|
||||
|
||||
|
||||
class TestProvider(Provider):
|
||||
"""Test provider"""
|
||||
|
||||
|
||||
class TestDependency(Dependency):
|
||||
provider_class = TestProvider
|
||||
|
||||
|
||||
class DependencyClassTestCase(BaseTestCase):
|
||||
def test_file_patching(self):
|
||||
test_replace_text = 'replaced_text'
|
||||
|
||||
temporary_directory = mkdtemp()
|
||||
path_temporary_directory = Path(temporary_directory)
|
||||
path_test_file = path_temporary_directory / 'test_file.css'
|
||||
|
||||
with open(path_test_file, mode='w') as file_object:
|
||||
file_object.write(
|
||||
'@import url("https://fonts.googleapis.com/css?family=Lato:400,700,400italic");'
|
||||
)
|
||||
|
||||
dependency = TestDependency(name='test_dependency', module=__name__)
|
||||
replace_list = [
|
||||
{
|
||||
'filename_pattern': '*',
|
||||
'content_patterns': [
|
||||
{
|
||||
'search': '"https://fonts.googleapis.com/css?family=Lato:400,700,400italic"',
|
||||
'replace': test_replace_text,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
dependency.patch_files(path=temporary_directory, replace_list=replace_list)
|
||||
|
||||
with open(path_test_file, mode='r') as file_object:
|
||||
final_text = file_object.read()
|
||||
|
||||
shutil.rmtree(temporary_directory, ignore_errors=True)
|
||||
|
||||
self.assertEqual(final_text, '@import url({});'.format(test_replace_text))
|
||||
Reference in New Issue
Block a user