• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iplweb / bpp / 49150ee2-a89b-4df8-9538-55cb06c06872

24 Aug 2025 11:07PM UTC coverage: 42.715% (+1.5%) from 41.169%
49150ee2-a89b-4df8-9538-55cb06c06872

push

circleci

mpasternak
Merge branch 'release/v202508.1207'

1 of 1 new or added line in 1 file covered. (100.0%)

1119 existing lines in 82 files now uncovered.

16660 of 39003 relevant lines covered (42.71%)

1.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/bpp/tests/test_admin/test_templateadmin.py
UNCOV
1
import pytest
×
UNCOV
2
from dbtemplates.models import Template
×
UNCOV
3
from django.urls import reverse
×
4

UNCOV
5
from django.contrib.contenttypes.models import ContentType
×
6

UNCOV
7
from bpp.models import Wydawnictwo_Ciagle
×
UNCOV
8
from bpp.models.szablondlaopisubibliograficznego import SzablonDlaOpisuBibliograficznego
×
9

10

UNCOV
11
@pytest.mark.django_db
×
UNCOV
12
def test_BppTemplateAdmin_templatka_zmienia_rekordy(
×
13
    admin_app, wydawnictwo_zwarte, denorms, wydawnictwo_ciagle
14
):
15
    WERSJA_1 = "werjsa 1"
×
16
    WERSJA_2 = "wersja 2"
×
17

18
    t, _ign = Template.objects.update_or_create(
×
19
        name="opis_bibliograficzny.html",
20
        defaults={"content": WERSJA_1},
21
    )
22
    SzablonDlaOpisuBibliograficznego.objects.create(
×
23
        model=ContentType.objects.get_for_model(Wydawnictwo_Ciagle),
24
        template=t,
25
    )
26
    denorms.rebuild_instances_of(Wydawnictwo_Ciagle)
×
27
    denorms.flush()
×
28

29
    wydawnictwo_ciagle.refresh_from_db()
×
30
    assert wydawnictwo_ciagle.opis_bibliograficzny_cache == WERSJA_1
×
31
    #
32
    # Koniec inicjalizacji -- właściwy test poniżej
33
    #
34

35
    url = reverse("admin:dbtemplates_template_change", args=(t.pk,))
×
36
    res = admin_app.get(url)
×
37
    res.forms["template_form"]["content"] = WERSJA_2
×
38
    res.forms["template_form"]["name"] = "nazwa.html"
×
39
    res = res.forms["template_form"].submit().maybe_follow()
×
40

41
    denorms.flush()
×
42

43
    wydawnictwo_ciagle.refresh_from_db()
×
44
    assert wydawnictwo_ciagle.opis_bibliograficzny_cache == WERSJA_2
×
45

46

UNCOV
47
@pytest.mark.django_db
×
UNCOV
48
def test_BppTemplateAdmin_zmiana_szablonu_zmienia_rekordy(
×
49
    admin_app, denorms, wydawnictwo_ciagle
50
):
51
    WERSJA_1 = "werjsa 1"
×
52
    WERSJA_2 = "wersja 2"
×
53

54
    t1, _ign = Template.objects.update_or_create(
×
55
        name="opis_bibliograficzny.html",
56
        defaults={"content": WERSJA_1},
57
    )
58
    t2, _ign = Template.objects.update_or_create(
×
59
        name="opis_bibliograficzny_2.html", defaults={"content": WERSJA_2}
60
    )
61

62
    szablon = SzablonDlaOpisuBibliograficznego.objects.create(
×
63
        model=ContentType.objects.get_for_model(Wydawnictwo_Ciagle),
64
        template=t1,
65
    )
66
    denorms.rebuildall()
×
67

68
    wydawnictwo_ciagle.refresh_from_db()
×
69
    assert wydawnictwo_ciagle.opis_bibliograficzny_cache == WERSJA_1
×
70

71
    #
72
    # Koniec inicjalizacji -- właściwy test poniżej
73
    #
74

75
    url = reverse(
×
76
        "admin:bpp_szablondlaopisubibliograficznego_change", args=(szablon.pk,)
77
    )
78
    res = admin_app.get(url)
×
79

80
    form = res.forms["szablondlaopisubibliograficznego_form"]
×
81
    form["template"].value = t2.pk
×
82
    res = form.submit().maybe_follow()
×
83

84
    denorms.flush()
×
85

86
    wydawnictwo_ciagle.refresh_from_db()
×
87
    assert wydawnictwo_ciagle.opis_bibliograficzny_cache == WERSJA_2
×
88

89

UNCOV
90
@pytest.fixture
×
UNCOV
91
def typowy_szablon_opisu():
×
92
    t, _ign = Template.objects.update_or_create(
×
93
        name="opis_bibliograficzny.html",
94
        defaults={"content": "123"},
95
    )
96
    SzablonDlaOpisuBibliograficznego.objects.update_or_create(
×
97
        model=None,
98
        template=t,
99
    )
100
    return t
×
101

102

UNCOV
103
@pytest.mark.django_db
×
UNCOV
104
def test_dbtemplates_TemplateAdmin_preview_good(
×
105
    typowy_szablon_opisu, admin_client, wydawnictwo_ciagle
106
):
107

108
    TEST_STR = b"456"
×
109
    res = admin_client.get(
×
110
        "/admin/dbtemplates/template/preview/", {"template": TEST_STR}, follow=True
111
    )
112
    assert TEST_STR in res.content
×
113

114

UNCOV
115
@pytest.mark.django_db
×
UNCOV
116
def test_dbtemplates_TemplateAdmin_preview_bad(typowy_szablon_opisu, admin_client):
×
117

118
    res = admin_client.get(
×
119
        "/admin/dbtemplates/template/preview/", {"template": "{% if foobar %}"}
120
    )
121
    assert "Wystąpił błąd" in res.rendered_content
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc