File: test_toml.py

package info (click to toggle)
staticsite 2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 14,648 kB
  • sloc: javascript: 33,722; python: 9,851; makefile: 46; sh: 4
file content (38 lines) | stat: -rw-r--r-- 841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from unittest import TestCase

import toml

from staticsite.utils import front_matter

toml_valid = """+++
date = "Tue, 24 Aug 2010 13:13:38 +0000"
tags = [ "valid" ]
bool = true
+++
"""

toml_invalid_bool = """+++
date = "Tue, 24 Aug 2010 13:13:38 +0000"
tags = [ "bug" ]
bool = True
+++
"""


class TestToml(TestCase):
    def test_valid(self):
        self.maxDiff = None
        fmt, data = front_matter.read_string(toml_valid)
        self.assertEqual(fmt, "toml")
        self.assertEqual(
            data,
            {
                "date": "Tue, 24 Aug 2010 13:13:38 +0000",
                "tags": ["valid"],
                "bool": True,
            },
        )

    def test_invalid_bool(self):
        with self.assertRaises(toml.decoder.TomlDecodeError):
            fmt, data = front_matter.read_string(toml_invalid_bool)