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)
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"))
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"]))
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)
def setUp(self): cfg = Settings.config_parser() self.theme = Theme(cfg)
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"))