Esempio n. 1
0
def test_yarn_allow_files(settings):
    systematize = 'systematize/build/systematize.css'
    syspath = settings.DJANGO_ROOT / 'node_modules' / systematize
    assert isfile(syspath)
    assert isfile(syspath.with_suffix('.min.css'))

    clean_yarn_settings(settings)
    settings.YARN_ALLOW_FILES = None
    settings.YARN_ROOT_PATH = settings.DJANGO_ROOT.as_posix()
    settings.YARN_STATIC_FILES_PREFIX = 'yarn-testing'

    findpath = joinpath('yarn-testing', systematize)
    finder = YarnFinder()
    assert not finder.find(findpath)
    assert not list(finder.list(None))

    settings.YARN_ALLOW_FILES = [systematize]

    finder = YarnFinder()
    assert syspath.samefile(finder.find(findpath))
    # PurePath is needed because Windows
    assert [PurePath(a)
            for a, b in finder.list(None)] == [PurePath(systematize)]

    settings.YARN_ALLOW_FILES = ['systematize/build/*.css']

    finder = YarnFinder()
    assert count(finder.list(None)) == 2
Esempio n. 2
0
def test_yarn_finder(settings):
    systematize = 'systematize/build/systematize.css'
    syspath = settings.DJANGO_ROOT / 'node_modules' / systematize
    assert isfile(syspath)

    clean_yarn_settings(settings)

    findpath = joinpath('yarn-testing', systematize)
    finder = YarnFinder()
    assert not finder.find(findpath)

    settings.YARN_ROOT_PATH = settings.DJANGO_ROOT.as_posix()
    settings.YARN_STATIC_FILES_PREFIX = 'yarn-testing'

    finder = YarnFinder()
    assert syspath.samefile(finder.find(findpath))

    clean_yarn_settings(settings)
    settings.NPM_ROOT_PATH = settings.DJANGO_ROOT.as_posix()
    settings.NPM_STATIC_FILES_PREFIX = 'yarn-testing'

    finder = YarnFinder()
    assert syspath.samefile(finder.find(findpath))
Esempio n. 3
0
def test_no_matching_paths_returns_empty_list(yarn_dir):
    with override_settings(YARN_FILE_PATTERNS={'foo': ['bar']}):
        f = YarnFinder()
        assert f.find('mocha/mocha.js') == []
Esempio n. 4
0
def test_finder_with_patterns_in_subdirectory(yarn_dir):
    with override_settings(YARN_STATIC_FILES_PREFIX='lib',
                           YARN_FILE_PATTERNS={'mocha': ['*']}):
        f = YarnFinder()
        assert f.find('lib/mocha/mocha.js')
Esempio n. 5
0
def test_finder_in_subdirectory(yarn_dir):
    with override_settings(YARN_STATIC_FILES_PREFIX='lib'):
        f = YarnFinder()
        assert f.find('lib/mocha/mocha.js')
Esempio n. 6
0
def test_finder_find(yarn_dir):
    f = YarnFinder()
    file = f.find('mocha/mocha.js')
    assert file
Esempio n. 7
0
def test_finder_with_patterns_in_directory_component(npm_dir):
    with override_settings(YARN_STATIC_FILES_PREFIX='lib',
                           YARN_FILE_PATTERNS={'mocha': ['*/*js']}):
        f = YarnFinder()
        assert f.find('lib/mocha/lib/test.js')