def test_find_dependencies(self): compiler = SCSS() files = { "A.scss": "@import 'B/C.scss';", "B/C.scss": "@import '../E';", "_E.scss": "p {color: red;}", "compass-import.scss": '@import "compass"', } compiler.get_source = MagicMock(side_effect=lambda x: files[x]) root = os.path.dirname(__file__) existing_files = set() for f in files: existing_files.add(os.path.join(root, "static", normalize_path(f))) with patch("os.path.exists") as mocked_os_path_exist: mocked_os_path_exist.side_effect = lambda x: x in existing_files self.assertEqual( compiler.find_dependencies("A.scss"), ["B/C.scss", "_E.scss"] ) self.assertEqual( compiler.find_dependencies("B/C.scss"), ["_E.scss"] ) self.assertEqual( compiler.find_dependencies("_E.scss"), [] )
def test_find_dependencies(self): compiler = SCSS() files = { "A.scss": "@import 'B/C.scss';", "B/C.scss": "@import '../E';", "_E.scss": "p {color: red;}", } compiler.get_source = MagicMock(side_effect=lambda x: files[x]) existing_files = set() for f in files: existing_files.add(os.path.join(STATIC_ROOT, f)) with patch("os.path.exists") as mocked_os_path_exist: mocked_os_path_exist.side_effect = lambda x: x in existing_files self.assertEqual( compiler.find_dependencies("A.scss"), ["B/C.scss", "_E.scss"] ) self.assertEqual( compiler.find_dependencies("B/C.scss"), ["_E.scss"] ) self.assertEqual( compiler.find_dependencies("_E.scss"), [] )
def test_find_dependencies(monkeypatch): compiler = SCSS() files = { "A.scss": "@import 'B/C.scss';", "B/C.scss": "@import '../E';", "_E.scss": "p {color: red;}", "compass-import.scss": '@import "compass"', } monkeypatch.setattr("static_precompiler.compilers.scss.SCSS.get_source", lambda self, x: files[x]) root = os.path.dirname(__file__) existing_files = set() for f in files: existing_files.add(os.path.join(root, "static", normalize_path(f))) monkeypatch.setattr("os.path.exists", lambda x: x in existing_files) assert compiler.find_dependencies("A.scss") == ["B/C.scss", "_E.scss"] assert compiler.find_dependencies("B/C.scss") == ["_E.scss"] assert compiler.find_dependencies("_E.scss") == []
def test_find_dependencies(monkeypatch): compiler = SCSS() files = { "A.scss": "@import 'B/C.scss';", "B/C.scss": "@import '../E';", "_E.scss": "p {color: red;}", "compass-import.scss": '@import "compass"', } monkeypatch.setattr("static_precompiler.compilers.scss.SCSS.get_source", lambda self, x: files[x]) root = os.path.dirname(__file__) existing_files = set() for f in files: existing_files.add(os.path.join(root, "static", normalize_path(f))) monkeypatch.setattr("os.path.exists", lambda x: x in existing_files) assert compiler.find_dependencies("A.scss") == ["B/C.scss", "_E.scss"] assert compiler.find_dependencies("B/C.scss") == ["_E.scss"] assert compiler.find_dependencies("_E.scss") == []