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

iplweb / bpp / 9e29adcd-8fa5-4a20-b4ec-b83dae9467cd

18 Apr 2025 09:43AM UTC coverage: 46.945%. Remained the same
9e29adcd-8fa5-4a20-b4ec-b83dae9467cd

push

circleci

mpasternak
Looking for failing test on GA

17332 of 36920 relevant lines covered (46.94%)

1.2 hits per line

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

84.85
src/bpp/tests/test_admin/test_crossref_api_sync.py
1
import base64
1✔
2

3
import pytest
1✔
4
from django.urls import reverse
1✔
5
from model_bakery import baker
1✔
6

7
from bpp.models import Autor, Rekord, Wydawnictwo_Ciagle
1✔
8

9
from django_bpp.selenium_util import wait_for, wait_for_page_load
1✔
10

11

12
@pytest.fixture
1✔
13
def autor_m():
1✔
14
    return baker.make(
1✔
15
        Autor,
16
        # base64, bo RODO:
17
        nazwisko=base64.decodebytes(b"TWllbG5pY3plaw==\n").decode("ascii"),
18
        imiona="Katarzyna",
19
    )
20

21

22
@pytest.mark.vcr
1✔
23
def test_crossref_api_autor_wo_selenium(admin_app, autor_m):
1✔
24

25
    url = "/admin/bpp/wydawnictwo_ciagle/pobierz-z-crossref/"
×
26
    page = admin_app.get(url)
×
27
    page.forms[1]["identyfikator_doi"] = "10.12775/jehs.2022.12.07.045"
×
28
    page = page.forms[1].submit().maybe_follow()
×
29
    if b"id_ustaw_orcid_button_author.0" not in page.content:
×
30
        page.showbrowser()
×
31
        raise Exception
×
32

33

34
@pytest.mark.vcr(ignore_localhost=True)
1✔
35
def test_crossref_api_autor_sync(admin_browser, live_server, transactional_db, autor_m):
1✔
36

37
    with wait_for_page_load(admin_browser):
1✔
38
        admin_browser.visit(
1✔
39
            live_server.url
40
            + reverse("admin:bpp_wydawnictwo_ciagle_add")
41
            + "../pobierz-z-crossref/"
42
        )
43

44
    admin_browser.find_by_name("identyfikator_doi").type("10.12775/jehs.2022.12.07.045")
1✔
45

46
    try:
1✔
47
        with wait_for_page_load(admin_browser):
1✔
48
            admin_browser.find_by_id("id_submit").click()
1✔
49

50
        admin_browser.find_by_id("id_ustaw_orcid_button_author.0")[0].click()
1✔
51

52
        def _():
1✔
53
            autor_m.refresh_from_db()
1✔
54
            return autor_m.orcid == "0000-0003-2575-3642"
1✔
55

56
        wait_for(_)
1✔
57
        assert True
1✔
58
    finally:
59
        autor_m.delete()
1✔
60

61

62
@pytest.fixture
1✔
63
def wydawnictwo_ciagle_jehs_2022():
1✔
64
    return baker.make(
1✔
65
        Wydawnictwo_Ciagle,
66
        doi="10.12775/jehs.2022.12.07.045",
67
        tytul_oryginalny="Neurological and neuropsychological post-covid complications",
68
    )
69

70

71
@pytest.fixture
1✔
72
def admin_browser_strona_porownania(admin_browser, live_server):
1✔
73
    with wait_for_page_load(admin_browser):
1✔
74
        admin_browser.visit(
1✔
75
            live_server.url
76
            + reverse("admin:bpp_wydawnictwo_ciagle_add")
77
            + "../pobierz-z-crossref/"
78
        )
79

80
    admin_browser.find_by_name("identyfikator_doi").type("10.12775/jehs.2022.12.07.045")
1✔
81

82
    with wait_for_page_load(admin_browser):
1✔
83
        admin_browser.find_by_id("id_submit").click()
1✔
84

85
    return admin_browser
1✔
86

87

88
@pytest.mark.django_db
1✔
89
@pytest.mark.vcr(ignore_localhost=True)
1✔
90
def test_crossref_api_strony_view(
1✔
91
    wydawnictwo_ciagle_jehs_2022,
92
    csrf_exempt_django_admin_app,
93
):
94

95
    csrf_exempt_django_admin_app.post(
×
96
        reverse("bpp:api_ustaw_strony"),
97
        {"rekord": Rekord.objects.all().first().form_post_pk, "strony": "447-452"},
98
    )
99

100
    wydawnictwo_ciagle_jehs_2022.refresh_from_db()
×
101

102
    return wydawnictwo_ciagle_jehs_2022.strony == "447-452"
×
103

104

105
@pytest.mark.vcr(ignore_localhost=True)
1✔
106
@pytest.mark.parametrize(
1✔
107
    "id_przycisku, atrybut, wynik",
108
    [
109
        ("id_ustaw_strony_button", "strony", "447-452"),
110
        ("id_ustaw_tom_button", "tom", "12"),
111
        ("id_ustaw_nr_zeszytu_button", "nr_zeszytu", "7"),
112
    ],
113
)
114
def test_crossref_api_strony_sync_browser(
1✔
115
    transactional_db,
116
    wydawnictwo_ciagle_jehs_2022,
117
    live_server,
118
    admin_browser_strona_porownania,
119
    id_przycisku,
120
    atrybut,
121
    wynik,
122
):
123
    # Kliknij id_przycisku, sprawdz czy atrybut wydawnictwa jest rowny do wynik
124
    admin_browser_strona_porownania.find_by_id(id_przycisku)[0].click()
1✔
125

126
    def _():
1✔
127
        wydawnictwo_ciagle_jehs_2022.refresh_from_db()
1✔
128
        return getattr(wydawnictwo_ciagle_jehs_2022, atrybut, None) == wynik
1✔
129

130
    wait_for(_)
1✔
131

132
    assert True
1✔
133

134

135
def test_crossref_api_streszczenie_sync_browser(
1✔
136
    transactional_db,
137
    wydawnictwo_ciagle_jehs_2022,
138
    live_server,
139
    admin_browser_strona_porownania,
140
):
141
    # Kliknij id_przycisku, sprawdz czy atrybut wydawnictwa jest rowny do wynik
142
    admin_browser_strona_porownania.find_by_id("id_ustaw_streszczenie_button").click()
1✔
143

144
    def _():
1✔
145
        wydawnictwo_ciagle_jehs_2022.refresh_from_db()
1✔
146
        return wydawnictwo_ciagle_jehs_2022.streszczenia.exists()
1✔
147

148
    wait_for(_)
1✔
149

150
    assert True
1✔
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

© 2026 Coveralls, Inc