Beispiel #1
0
 def test_template_conf_dne(self):
     '''Test templating a string.'''
     theme_path = self.theme_dir / 'main.yaml'
     color_path = self.color_dir / 'main.yaml'
     (self.link_dir / 'theme.yaml').symlink_to(theme_path)
     (self.link_dir / 'color.yaml').symlink_to(color_path)
     theme_path.write_text('theme: cooltheme')
     host_cfg = HostConfig(self.theme_dir, self.color_dir)
     templater = Templater(self.link_dir, host_cfg)
     with self.assertRaises(LinkMalformedError):
         templater.template('theme: {{theme}}\ncolor: {{color}}')
Beispiel #2
0
 def test_template_after_set_color(self):
     '''Test that set_color changes the output even after first use.'''
     theme_path = self.theme_dir / 'main.yaml'
     color_path = self.color_dir / 'main.yaml'
     new_color_path = self.color_dir / 'new.yaml'
     (self.link_dir / 'theme.yaml').symlink_to(theme_path)
     (self.link_dir / 'color.yaml').symlink_to(color_path)
     theme_path.write_text('theme: cooltheme')
     color_path.write_text('color: coolcolor')
     new_color_path.write_text('color: newcolor')
     host_cfg = HostConfig(self.theme_dir, self.color_dir)
     templater = Templater(self.link_dir, host_cfg)
     templater.template('theme: {{theme}}\ncolor: {{color}}')
     templater.set_color('new')
     out_str = templater.template('theme: {{theme}}\ncolor: {{color}}')
     self.assertEqual(out_str, 'theme: cooltheme\ncolor: newcolor')
Beispiel #3
0
 def test_template(self):
     '''Test templating a string.'''
     theme_path = self.theme_dir / 'main.yaml'
     color_path = self.color_dir / 'main.yaml'
     (self.link_dir / 'theme.yaml').symlink_to(theme_path)
     (self.link_dir / 'color.yaml').symlink_to(color_path)
     theme_path.write_text('theme: cooltheme')
     color_path.write_text('color: coolcolor')
     host_cfg = HostConfig(self.theme_dir, self.color_dir)
     templater = Templater(self.link_dir, host_cfg)
     out_str = templater.template('theme: {{theme}}\ncolor: {{color}}')
     self.assertEqual(out_str, 'theme: cooltheme\ncolor: coolcolor')