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

iplweb / bpp / 0cececd7-a2e7-4a75-a26c-21df764ad54e

24 Aug 2025 10:29PM UTC coverage: 41.169% (-2.5%) from 43.704%
0cececd7-a2e7-4a75-a26c-21df764ad54e

push

circleci

mpasternak
Merge branch 'release/v202508.1206'

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

2674 existing lines in 124 files now uncovered.

16057 of 39003 relevant lines covered (41.17%)

0.76 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
UNCOV
1
import base64
×
2

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

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

UNCOV
9
from django_bpp.selenium_util import wait_for, wait_for_page_load
×
10

11

UNCOV
12
@pytest.fixture
×
UNCOV
13
def autor_m():
×
UNCOV
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

UNCOV
22
@pytest.mark.vcr
×
UNCOV
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

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

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

UNCOV
44
    admin_browser.find_by_name("identyfikator_doi").type("10.12775/jehs.2022.12.07.045")
×
45

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

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

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

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

61

UNCOV
62
@pytest.fixture
×
UNCOV
63
def wydawnictwo_ciagle_jehs_2022():
×
UNCOV
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

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

UNCOV
80
    admin_browser.find_by_name("identyfikator_doi").type("10.12775/jehs.2022.12.07.045")
×
81

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

UNCOV
85
    return admin_browser
×
86

87

UNCOV
88
@pytest.mark.django_db
×
UNCOV
89
@pytest.mark.vcr(ignore_localhost=True)
×
UNCOV
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

UNCOV
105
@pytest.mark.vcr(ignore_localhost=True)
×
UNCOV
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
)
UNCOV
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
UNCOV
124
    admin_browser_strona_porownania.find_by_id(id_przycisku)[0].click()
×
125

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

UNCOV
130
    wait_for(_)
×
131

UNCOV
132
    assert True
×
133

134

UNCOV
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
UNCOV
142
    admin_browser_strona_porownania.find_by_id("id_ustaw_streszczenie_button").click()
×
143

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

UNCOV
148
    wait_for(_)
×
149

UNCOV
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

© 2025 Coveralls, Inc