def test_compile_static(monkeypatch): compiler_stub = stub(compile=lambda x: "compiled", compile_lazy=lambda x: "compiled lazy") monkeypatch.setattr("static_precompiler.utils.get_compiler_by_path", lambda path: compiler_stub) assert compile_static("foo") == "compiled" assert compile_static_lazy("foo") == "compiled lazy"
def test_compile_static(monkeypatch): compiler_stub = stub( compile=lambda x: "compiled", compile_lazy=lambda x: "compiled lazy" ) monkeypatch.setattr("static_precompiler.utils.get_compiler_by_path", lambda path: compiler_stub) assert compile_static("foo") == "compiled" assert compile_static_lazy("foo") == "compiled lazy"
def test_compile_static_lazy(self): mocked_compiler = MagicMock() mocked_compiler.compile_lazy.return_value = "compiled" with patch("static_precompiler.utils.get_compilers") as mocked_get_compilers: mocked_get_compilers.return_value = [ mocked_compiler, ] self.assertEquals( compile_static_lazy("source"), "compiled" ) mocked_compiler.compile_lazy.assert_called_with("source")
def test_compile_static(self): mocked_compiler = MagicMock() mocked_compiler.compile.return_value = "compiled" mocked_compiler.compile_lazy.return_value = "compiled" source_filename = "test.coffee" with patch("static_precompiler.utils.get_compiler_by_path" ) as mocked_get_compiler_by_path: mocked_get_compiler_by_path.return_value = mocked_compiler self.assertEquals(compile_static(source_filename), "compiled") mocked_get_compiler_by_path.assert_called_once_with( source_filename) mocked_compiler.compile.assert_called_once_with(source_filename) mocked_get_compiler_by_path.reset_mock() self.assertEquals(compile_static_lazy(source_filename), "compiled") mocked_get_compiler_by_path.assert_called_once_with( source_filename) mocked_compiler.compile_lazy.assert_called_once_with( source_filename)