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:
Roberto Rosario
2019-06-08 17:36:58 -04:00
parent db5511127d
commit 2fcb36c568
22 changed files with 224 additions and 12637 deletions

View 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))