File: test_settings.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 (40 lines) | stat: -rw-r--r-- 1,059 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
39
40
import os
from unittest import TestCase

from staticsite import global_settings
from staticsite.settings import Settings

from .utils import datafile_abspath


class TestSettings(TestCase):
    def test_defaults(self):
        s = Settings()
        self.assertEqual(s.TIMEZONE, global_settings.TIMEZONE)

    def test_as_dict(self):
        s = Settings()
        d = s.as_dict()
        self.assertEqual(d["TIMEZONE"], global_settings.TIMEZONE)

    def test_add_module(self):
        s = Settings()
        self.assertFalse(hasattr(s, "PRIO_USER"))

        s.add_module(os)

        # Merging a module add all uppercase symbols
        self.assertEqual(s.PRIO_USER, os.PRIO_USER)

        # And ignores all lowercase ones
        self.assertFalse(hasattr(s, "getuid"))

    def test_load(self):
        s = Settings()
        self.assertFalse(hasattr(s, "UPPERCASE"))

        s.load(datafile_abspath("settings.py"))

        self.assertEqual(s.UPPERCASE, True)
        self.assertFalse(hasattr(s, "lowercase"))
        self.assertFalse(hasattr(s, "os"))