コード例 #1
0
 def test_topic_loader_valid_name_text(self):
     config_file = "topic-1/topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-1").name,
         "Topic 1",
     )
コード例 #2
0
 def test_topic_loader_valid_icon(self):
     config_file = "topic-valid-icon/topic-valid-icon.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-valid-icon").icon,
         "img/logo.png",
     )
コード例 #3
0
 def test_topic_loader_valid_content_text(self):
     config_file = "topic-1/topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-1").content,
         "<p>Etiam in massa. Nam ut metus. In rhoncus venenatis tellus.</p>",
     )
コード例 #4
0
 def test_topic_loader_missing_icon(self):
     content_path, structure_filename = "topic-1", "topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     # Passes if loader throws no exception
     topic_loader.load()
コード例 #5
0
 def test_topic_loader_curriculum_integrations_empty(self):
     content_path = "empty-curriculum-integrations"
     structure_filename = "empty-curriculum-integrations.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     # Passes if loader throws no exception
     topic_loader.load()
コード例 #6
0
 def test_topic_loader_programming_challenges_empty(self):
     content_path = "empty-programming-challenges"
     structure_filename = "empty-programming-challenges.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     # Passes if loader throws no exception
     topic_loader.load()
コード例 #7
0
 def test_basic_topic_loader_configuration(self):
     content_path, structure_filename = "topic-1", "topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     self.assertQuerysetEqual(Topic.objects.all(), ["<Topic: Topic 1>"])
     self.assertSetEqual(set(["en"]),
                         set(Topic.objects.get(slug="topic-1").languages))
コード例 #8
0
 def test_topic_loader_with_other_resources(self):
     content_path, structure_filename = "topic-with-other-resources", "topic-with-other-resources.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     # Passes if loader throws no exception
     topic_loader.load()
     topic = Topic.objects.get(slug="topic-with-other-resources")
     self.assertIn("Other resources content.", topic.other_resources)
コード例 #9
0
 def test_topic_loader_empty_icon(self):
     content_path = "empty-icon"
     structure_filename = "empty-icon.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     topic = Topic.objects.get(slug="empty-icon")
     self.assertIsNone(topic.icon)
コード例 #10
0
 def test_topic_loader_other_resources_empty(self):
     content_path = "empty-other-resources"
     structure_filename = "empty-other-resources.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     topic = Topic.objects.get(slug="empty-other-resources")
     self.assertEqual(topic.other_resources, "")
コード例 #11
0
 def test_topic_loader_valid_content_text(self):
     content_path, structure_filename = "topic-1", "topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-1").content,
         "<p>Etiam in massa. Nam ut metus. In rhoncus venenatis tellus.</p>",
     )
コード例 #12
0
 def test_topic_loader_valid_name_text(self):
     content_path, structure_filename = "topic-1", "topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-1").name,
         "Topic 1",
     )
コード例 #13
0
 def test_topic_loader_valid_icon(self):
     content_path, structure_filename = "topic-valid-icon", "topic-valid-icon.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     topic_loader.load()
     self.assertEquals(
         Topic.objects.get(slug="topic-valid-icon").icon,
         "img/logo.png",
     )
コード例 #14
0
 def test_topic_loader_missing_unit_plans(self):
     config_file = "topic-missing-unit-plans/topic-missing-unit-plans.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     self.assertRaises(
         MissingRequiredFieldError,
         topic_loader.load,
     )
コード例 #15
0
 def test_topic_loader_missing_configuration_file(self):
     config_file = "topic-1/topic-missing.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     self.assertRaises(
         CouldNotFindConfigFileError,
         topic_loader.load,
     )
コード例 #16
0
 def test_topic_loader_missing_content_text(self):
     config_file = "topic-missing-content/topic-missing-content.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     self.assertRaises(
         EmptyMarkdownFileError,
         topic_loader.load,
     )
コード例 #17
0
 def test_topic_loader_missing_name_text(self):
     config_file = "topic-missing-name/topic-missing-name.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     self.assertRaises(
         NoHeadingFoundInMarkdownFileError,
         topic_loader.load,
     )
コード例 #18
0
    def test_topic_translation_other_resources_missing(self):
        content_path = "topic-translation-other-resources-missing"
        structure_filename = "topic-translation-other-resources-missing.yaml"
        factory = Mock()
        topic_loader = TopicLoader(factory,
                                   content_path=content_path,
                                   base_path=self.base_path,
                                   structure_filename=structure_filename)
        # Passes if loader throws no exception
        topic_loader.load()
        topic = Topic.objects.get(
            slug="topic-translation-other-resources-missing")

        # 'de' should still be an available language as other_resources is optional
        self.assertSetEqual(set(["en", "de"]), set(topic.languages))
        self.assertIn("English other resources content.",
                      topic.other_resources)
        with translation.override("de"):
            # accessing the untranslated field should not default back to english
            self.assertEqual("", topic.other_resources)
コード例 #19
0
 def test_topic_loader_missing_unit_plans(self):
     content_path, structure_filename = "topic-missing-unit-plans", "topic-missing-unit-plans.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     self.assertRaises(
         MissingRequiredFieldError,
         topic_loader.load,
     )
コード例 #20
0
 def test_topic_loader_missing_content_text(self):
     content_path, structure_filename = "topic-missing-content", "topic-missing-content.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     self.assertRaises(
         EmptyMarkdownFileError,
         topic_loader.load,
     )
コード例 #21
0
 def test_topic_loader_missing_name_text(self):
     content_path, structure_filename = "topic-missing-name", "topic-missing-name.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     self.assertRaises(
         NoHeadingFoundInMarkdownFileError,
         topic_loader.load,
     )
コード例 #22
0
 def test_topic_loader_missing_configuration_file(self):
     content_path, structure_filename = "topic-1", "topic-missing.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory,
                                content_path=content_path,
                                base_path=self.base_path,
                                structure_filename=structure_filename)
     self.assertRaises(
         CouldNotFindYAMLFileError,
         topic_loader.load,
     )
コード例 #23
0
    def test_topic_translation(self):
        content_path, structure_filename = "topic-translation", "topic-translation.yaml"
        factory = Mock()
        topic_loader = TopicLoader(factory,
                                   content_path=content_path,
                                   base_path=self.base_path,
                                   structure_filename=structure_filename)
        # Passes if loader throws no exception
        topic_loader.load()
        topic = Topic.objects.get(slug="topic-translation")

        self.assertSetEqual(set(["en", "de"]), set(topic.languages))

        self.assertEqual("English Heading", topic.name)
        self.assertIn("English topic content", topic.content)
        self.assertIn("English other resources content.",
                      topic.other_resources)

        with translation.override("de"):
            self.assertEqual("German Heading", topic.name)
            self.assertIn("German topic content", topic.content)
            self.assertIn("German other resources content.",
                          topic.other_resources)
コード例 #24
0
 def create_topic_loader(self, structure_file_path, BASE_PATH):
     """Create topic loader."""
     return TopicLoader(self, structure_file_path, BASE_PATH)
コード例 #25
0
 def test_topic_loader_missing_icon(self):
     config_file = "topic-1/topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     # Passes if loader throws no exception
     topic_loader.load()
コード例 #26
0
 def test_basic_topic_loader_configuration(self):
     config_file = "topic-1/topic-1.yaml"
     factory = Mock()
     topic_loader = TopicLoader(factory, config_file, self.BASE_PATH)
     topic_loader.load()
     self.assertQuerysetEqual(Topic.objects.all(), ["<Topic: Topic 1>"])
コード例 #27
0
 def create_topic_loader(self, **kwargs):
     """Create topic loader."""
     return TopicLoader(self, **kwargs)