From f90cc146861e1523f50d29fa1e90ded32e351428 Mon Sep 17 00:00:00 2001 From: ifaint Date: Thu, 25 Mar 2021 11:59:05 +0800 Subject: [PATCH] Added tests for #556. --- tests/base_test_mixins.py | 2 +- tests/test_content.py | 3 ++- tests/test_sandbox.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/base_test_mixins.py b/tests/base_test_mixins.py index 8d75ecfd1..2bdea7b04 100644 --- a/tests/base_test_mixins.py +++ b/tests/base_test_mixins.py @@ -69,7 +69,7 @@ "hidden": False, "listed": True, "accepts_enrollment": True, - "git_source": "git://github.com/inducer/relate-sample", + "git_source": "git://github.com/dzhuang/relate-sample", "course_file": "course.yml", "events_file": "events.yml", "enrollment_approval_required": False, diff --git a/tests/test_content.py b/tests/test_content.py index 6a027350c..44cbf8d43 100644 --- a/tests/test_content.py +++ b/tests/test_content.py @@ -853,7 +853,8 @@ def test_load_not_yaml(self): with self.pctx.repo as repo: loader = content.YamlBlockEscapingGitTemplateLoader( repo, self.course.active_git_commit_sha.encode()) - result = loader.get_source(environment, "content-macros.jinja") + result = loader.get_source(environment, + "macros/content-macros.jinja") source, _, _ = result self.assertIsNotNone(source) self.assertTrue(source.startswith( diff --git a/tests/test_sandbox.py b/tests/test_sandbox.py index 74f78ed8c..eb4169086 100644 --- a/tests/test_sandbox.py +++ b/tests/test_sandbox.py @@ -381,3 +381,15 @@ def test_preview_failed(self): self.assertEqual(resp.status_code, 200) self.assertAddMessageCallCount(1) self.assertAddMessageCalledWith(error_msg) + + def test_subdir_macro_render(self): + # Test https://github.com/inducer/relate/pull/556 + # Also see https://github.com/inducer/relate/issues/767 + markup_content = """ +{% from "macros/test/test-macro.jinja" import button %} +{{ button("flow:exam-1") }}""" + resp = self.post_markup_sandbox_view(markup_content=markup_content) + self.assertEqual(resp.status_code, 200) + self.assertContains( + resp, "/course/%s/flow/exam-1/start" % self.course.identifier, + status_code=200)