コード例 #1
0
    def test_set_refresh_enabled(self):
        text = textwrap.dedent("""
        .. entity:: THEME_SETTINGS

        Scene
        =====

        one
        ---

        .. property:: THEME_SETTINGS.punchline-states-refresh none

        two
        ---

        .. property:: THEME_SETTINGS.punchline-states-refresh inherit

        """)
        theme = Theme()
        script = SceneScript("inline", doc=SceneScript.read(text))
        script.cast(script.select([theme.settings]))
        model = ModelAssignsStrings(script.fP, script.doc)
        script.doc.walkabout(model)
        presenter = Presenter(model)
        self.assertEqual(2, len(presenter.frames))
        presenter.animate(presenter.frames[0])
        self.assertEqual("none", theme.refresh_target)
        presenter.animate(presenter.frames[1])
        self.assertEqual("inherit", theme.refresh_target)
コード例 #2
0
    def test_empty_feed(self):
        theme = Theme()
        settings = theme.get_feed_settings("")
        self.assertIn("feed_url", settings)
        self.assertIn("feed_title", settings)

        rv = theme.publish([], **settings)
        self.assertEqual("https://jsonfeed.org/version/1.1", rv.get("version"))
コード例 #3
0
    def test_publish_multipages(self):
        text = textwrap.dedent("""
        Page One
        ========

        Shot One
        --------

        The text.

        .. fx:: tor.static.img  street.jpg
           :offset: 0
           :duration: 0

        Page Two
        ========

        Shot Two
        --------

        More text.

        .. fx:: turberfield.punchline.media  audio/fly_away.mp3
           :offset: 0
           :duration: 8000
           :loop: 12

        """)
        cfg = Settings.config_parser()
        theme = Theme(cfg)
        pages = list(Build.build_pages(text, theme))
        self.assertEqual(2, len(pages), pages)
        self.assertIsInstance(pages[0], Site.Page)
        self.assertIsInstance(pages[1], Site.Page)

        theme = Theme()
        pages = itertools.chain.from_iterable(
            theme.expand(i, output=pathlib.Path(".")) for i in pages)
        settings = theme.get_feed_settings("all")
        feed = theme.publish(pages, **settings)
        self.assertEqual(2, len(feed["items"]))
コード例 #4
0
    def test_widgets(self):
        cfg = Settings.config_parser()
        theme = Theme(cfg)
        self.assertEqual(1, len(theme.widgets))

        cfg.add_section("turberfield.punchline")
        self.assertEqual(2, len(theme.widgets))

        catalogue = Widget.register(
            Widget("turberfield.punchline", "css", config="a.com"))
        self.assertEqual(2, len(theme.widgets))

        cfg.add_section("a.com")
        widgets = theme.widgets
        self.assertEqual(3, len(theme.widgets))
        self.assertEqual("jsonfeed.org", widgets[0].config)
        self.assertEqual("turberfield.punchline", widgets[1].config)
        self.assertEqual("a.com", widgets[2].config)
コード例 #5
0
 def setUp(self):
     cfg = Settings.config_parser()
     self.theme = Theme(cfg)
コード例 #6
0
 def test_settings(self):
     cfg = Settings.config_parser()
     theme = Theme(cfg)
     self.assertTrue(hasattr(theme, "settings"))
     self.assertIsInstance(theme.settings, Settings)
     self.assertTrue(hasattr(theme.settings, "id"))