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

iplweb / bpp / c5db2772-42ef-40cf-977b-8238df9ca907

21 Aug 2025 09:47AM UTC coverage: 46.22% (-0.06%) from 46.283%
c5db2772-42ef-40cf-977b-8238df9ca907

push

circleci

mpasternak
Merge branch 'release/v202508.1195'

3 of 3 new or added lines in 2 files covered. (100.0%)

2836 existing lines in 173 files now uncovered.

17625 of 38133 relevant lines covered (46.22%)

1.18 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
UNCOV
1
import base64
1✔
2

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

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

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

11

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

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

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

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

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

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

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

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

61

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

UNCOV
71
@pytest.fixture
1✔
UNCOV
72
def admin_browser_strona_porownania(admin_browser, live_server):
1✔
UNCOV
73
    with wait_for_page_load(admin_browser):
1✔
UNCOV
74
        admin_browser.visit(
1✔
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")
1✔
81

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

UNCOV
85
    return admin_browser
1✔
86

87

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

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

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

UNCOV
130
    wait_for(_)
1✔
131

UNCOV
132
    assert True
1✔
133

134

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

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

UNCOV
148
    wait_for(_)
1✔
149

UNCOV
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

© 2025 Coveralls, Inc