File: test_checkpreferences_command.py

package info (click to toggle)
django-dynamic-preferences 1.17.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 476 kB
  • sloc: python: 3,040; makefile: 3
file content (41 lines) | stat: -rw-r--r-- 1,036 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
41
from io import StringIO

from django.core.management import call_command


def call(*args, **kwargs):
    out = StringIO()
    call_command(
        "checkpreferences",
        *args,
        stdout=out,
        stderr=StringIO(),
        **kwargs,
    )
    return out.getvalue().strip()


def test_dry_run(db):
    out = call(verbosity=0)
    expected_output = "\n".join(
        [
            "Creating missing global preferences...",
            "Deleted 0 global preferences",
            "Deleted 0 GlobalPreferenceModel preferences",
            "Deleted 0 UserPreferenceModel preferences",
            "Creating missing preferences for User model...",
        ]
    )
    assert out == expected_output


def test_skip_create(db):
    out = call("--skip_create", verbosity=0)
    expected_output = "\n".join(
        [
            "Deleted 0 global preferences",
            "Deleted 0 GlobalPreferenceModel preferences",
            "Deleted 0 UserPreferenceModel preferences",
        ]
    )
    assert out == expected_output