def test_happy_path(self):
     dirpath = MockDir({
         "en/a-course/index.yaml":
         textwrap.dedent("""\
             title: Title
             introduction_html: |-
                 <p>Hi</p>
                 <p>Bye</p>
             lessons:
                 - lesson-1
                 - lesson-2
             """).encode("utf-8"),
         "en/a-course/lesson-1.html":
         (b"<header><h1>L1</h1><p>HP1</p></header>"
          b"<footer><h2>F1</h2><p>foot</p></footer>"),
         "en/a-course/lesson-2.html":
         (b"<header><h1>L2</h1><p>HP2</p></header>"
          b"<footer><h2>F2</h2><p>foot</p></footer>"),
     })
     course = Course.load_from_path(dirpath / "en" / "a-course" /
                                    "index.yaml")
     self.assertEqual(
         course,
         Course(
             slug="a-course",
             title="Title",
             locale_id="en",
             introduction_html="<p>Hi</p>\n<p>Bye</p>",
             lessons={
                 "lesson-1":
                 Lesson(
                     course,
                     "lesson-1",
                     "en",
                     header=LessonHeader("L1", "<p>HP1</p>"),
                     footer=LessonFooter("F1", "<p>foot</p>"),
                 ),
                 "lesson-2":
                 Lesson(
                     course,
                     "lesson-2",
                     "en",
                     header=LessonHeader("L2", "<p>HP2</p>"),
                     footer=LessonFooter("F2", "<p>foot</p>"),
                 ),
             },
         ),
     )
Exemple #2
0
 def test_parse_footer(self):
     out = Lesson.parse(
         None, 'a-slug', """
         <header><h1>x</h1><p>y</p></header>
         <footer><h2>Foot</h2><p>My foot</p></footer>
     """)
     self.assertEquals(out.footer, LessonFooter('Foot', '<p>My foot</p>'))
 def test_parse_footer(self):
     out = Lesson.parse(
         None,
         "a-slug",
         """
         <header><h1>x</h1><p>y</p></header>
         <footer><h2>Foot</h2><p>My foot</p></footer>
     """,
     )
     self.assertEquals(out.footer, LessonFooter("Foot", "<p>My foot</p>"))
Exemple #4
0
 def test_happy_path(self):
     dirpath = MockDir({
         'index.yaml':
         textwrap.dedent('''\
             title: Title
             introduction_html: |-
                 <p>Hi</p>
                 <p>Bye</p>
             lessons:
                 - lesson-1
                 - lesson-2
             ''').encode('utf-8'),
         'lesson-1.html': (b'<header><h1>L1</h1><p>HP1</p></header>'
                           b'<footer><h2>F1</h2><p>foot</p></footer>'),
         'lesson-2.html': (b'<header><h1>L2</h1><p>HP2</p></header>'
                           b'<footer><h2>F2</h2><p>foot</p></footer>'),
     })
     assert dirpath.name == 'root'  # we define this in 'utils'
     course = Course.load_from_path(dirpath / 'index.yaml')
     self.assertEqual(
         course,
         Course(
             slug='root',
             title='Title',
             introduction_html='<p>Hi</p>\n<p>Bye</p>',
             lessons={
                 'lesson-1':
                 Lesson(course,
                        'lesson-1',
                        header=LessonHeader('L1', '<p>HP1</p>'),
                        footer=LessonFooter('F1', '<p>foot</p>')),
                 'lesson-2':
                 Lesson(course,
                        'lesson-2',
                        header=LessonHeader('L2', '<p>HP2</p>'),
                        footer=LessonFooter('F2', '<p>foot</p>')),
             },
         ))