Пример #1
0
    def test_walk_nodes(self):
        files = [
            "blog/index.html",
            "blog/post.html",
            "index.html",
            "style.css",
        ]
        dirs = ["blog"]
        with TemporaryDirectory() as deploy, TemporaryDirectory() as content:
            settings = Config({"deploy_path": deploy, "content_path": content})
            for d in dirs:
                pathlib.Path(content, d).mkdir()

            for f in files:
                pathlib.Path(content, f).touch()

            gen(settings)

            for item in files + dirs:
                with self.subTest("%s exists in %s" % (item, deploy)):
                    self.assertTrue(pathlib.Path(deploy, item).exists())
Пример #2
0
 def test_no_load(self):
     settings = Config()
     self.assertEqual(len(settings), 0)
Пример #3
0
 def test_load_AssertionError(self):
     # raise an AssertionError if it's not a dict or file-like object
     with self.assertRaises(AssertionError):
         Config(12)
Пример #4
0
    def test_load_str(self):
        settings = Config(YAML_DATA)

        self.assertEqual(len(settings), 2)
        self.assertEqual(settings["sitename"], "bob")
        self.assertEqual(settings["thingy"], ["one", "two", "three"])
Пример #5
0
 def test_repr(self):
     settings = Config({})
     # just a smoke test to make sure it doesn't blow up
     self.assertTrue(isinstance(repr(settings), str))
     self.assertTrue(repr(settings))
Пример #6
0
 def test_get_name_for_node_config(self):
     node = mock.Mock()
     node.full_path = "this-file.html"
     config = Config({}, parent=mock.Mock(), node=node)
     self.assertEqual(config.get_name(), node.full_path)
Пример #7
0
 def test_get_name_for_root_config(self):
     config = Config({})
     self.assertEqual(config.get_name(), SITE_YAML_PATH)
Пример #8
0
    def test_len_with_parent(self):
        parent = Config({"test": True})
        settings = Config(YAML_DATA, parent=parent, node=mock.Mock())

        self.assertEqual(len(settings), 3)
        self.assertEqual(len(parent), 1)
Пример #9
0
    def test_len(self):
        settings = Config(YAML_DATA)

        self.assertEqual(len(settings), 2)
Пример #10
0
    def test_contains(self):
        settings = Config(YAML_DATA)

        self.assertIn("sitename", settings)
        self.assertIn("thingy", settings)
        self.assertNotIn("test", settings)
Пример #11
0
    def test_items(self):
        settings = Config(YAML_DATA)

        self.assertCountEqual(list(settings.items()),
                              [("sitename", "bob"),
                               ("thingy", ["one", "two", "three"])])
Пример #12
0
    def test_values(self):
        settings = Config(YAML_DATA)

        self.assertCountEqual(list(settings.values()),
                              ["bob", ["one", "two", "three"]])
Пример #13
0
    def test_iter(self):
        settings = Config(YAML_DATA)

        self.assertCountEqual(list(settings), ["sitename", "thingy"])