Пример #1
0
 def test_chapters_chapter_loader_valid_video_url(self):
     test_slug = "valid-video-url"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     chapter_loader.load()
     self.assertEqual(
         Chapter.objects.get(slug=test_slug).video,
         "https://player.vimeo.com/video/58336187")
Пример #2
0
 def test_chapters_chapter_loader_single_chapter(self):
     test_slug = "chapter-1"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     chapter_loader.load()
     self.assertQuerysetEqual(Chapter.objects.all(),
                              ["<Chapter: Chapter 1>"])
     self.assertSetEqual(
         set(["en"]), set(Chapter.objects.get(slug="chapter-1").languages))
Пример #3
0
 def test_chapters_chapter_loader_no_icon(self):
     test_slug = "no-icon"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     self.assertRaises(MissingRequiredFieldError, chapter_loader.load)
Пример #4
0
 def test_chapters_chapter_loader_introduction_missing_content(self):
     test_slug = "missing-content"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     self.assertRaises(EmptyMarkdownFileError, chapter_loader.load)
Пример #5
0
 def test_chapters_chapter_loader_invalid_video_url(self):
     test_slug = "invalid-video-url"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     self.assertRaises(ValueError, chapter_loader.load)
Пример #6
0
 def test_chapters_chapter_loader_interactive_invalid(self):
     test_slug = "invalid-interactive"
     factory = mock.Mock()
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     self.assertRaises(KeyNotFoundError, chapter_loader.load)
Пример #7
0
 def test_chapters_chapter_loader_interactive(self):
     test_slug = "interactives"
     factory = mock.Mock()
     interactive1 = self.interactives_test_data.create_interactive(1)
     interactive2 = self.interactives_test_data.create_interactive(2)
     interactive3 = self.interactives_test_data.create_interactive(3)
     chapter_loader = ChaptersLoader(
         factory,
         chapter_number=1,
         content_path=test_slug,
         base_path=self.base_path,
         structure_filename="{}.yaml".format(test_slug))
     chapter_loader.load()
     self.assertQuerysetEqual(Chapter.objects.all(),
                              ["<Chapter: Interactives>"])
     self.assertEqual(
         list(
             Chapter.objects.get(
                 slug=test_slug).interactives.order_by("slug")), [
                     interactive1,
                     interactive2,
                     interactive3,
                 ])
Пример #8
0
 def create_chapter_loader(self, **kwargs):
     """Create chapter loader."""
     return ChaptersLoader(self, **kwargs)