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

iplweb / bpp / fa7eeabe-4bfd-4290-a6fc-42dc6b494c59

11 Aug 2025 10:16AM UTC coverage: 42.456% (-3.8%) from 46.303%
fa7eeabe-4bfd-4290-a6fc-42dc6b494c59

push

circleci

mpasternak
Fix redis-cli not found

16082 of 37879 relevant lines covered (42.46%)

0.77 hits per line

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

0.0
src/bpp/tests/test_admin/test_crossref_api_sync.py
1
import base64
×
2

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

7
from bpp.models import Autor, Rekord, Wydawnictwo_Ciagle
×
8

9
from django_bpp.selenium_util import wait_for, wait_for_page_load
×
10

11

12
@pytest.fixture
×
13
def autor_m():
×
14
    return baker.make(
×
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
×
23
def test_crossref_api_autor_wo_selenium(admin_app, autor_m):
×
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)
×
35
def test_crossref_api_autor_sync(admin_browser, live_server, transactional_db, autor_m):
×
36

37
    with wait_for_page_load(admin_browser):
×
38
        admin_browser.visit(
×
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")
×
45

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

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

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

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

61

62
@pytest.fixture
×
63
def wydawnictwo_ciagle_jehs_2022():
×
64
    return baker.make(
×
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
×
72
def admin_browser_strona_porownania(admin_browser, live_server):
×
73
    with wait_for_page_load(admin_browser):
×
74
        admin_browser.visit(
×
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")
×
81

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

85
    return admin_browser
×
86

87

88
@pytest.mark.django_db
×
89
@pytest.mark.vcr(ignore_localhost=True)
×
90
def test_crossref_api_strony_view(
×
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)
×
106
@pytest.mark.parametrize(
×
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(
×
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()
×
125

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

130
    wait_for(_)
×
131

132
    assert True
×
133

134

135
def test_crossref_api_streszczenie_sync_browser(
×
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()
×
143

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

148
    wait_for(_)
×
149

150
    assert True
×
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