invenio-app-rdm 13.0.0rc4__py2.py3-none-any.whl → 13.0.0rc6__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- invenio_app_rdm/__init__.py +1 -1
- invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/doi.html +7 -5
- invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/components/CopyButton.js +38 -19
- invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/ExportDropdown.js +7 -2
- invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/theme.js +4 -0
- invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/theme.js +9 -0
- invenio_app_rdm/theme/assets/semantic-ui/less/invenio_app_rdm/theme/globals/site.overrides +6 -1
- invenio_app_rdm/theme/webpack.py +0 -1
- invenio_app_rdm/upgrade_scripts/migrate_12_0_to_13_0.py +94 -65
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/METADATA +17 -2
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/RECORD +15 -55
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/top_level.txt +0 -1
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/i18next-scanner.config.js +0 -64
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/package-lock.json +0 -2129
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/compileCatalog.js +0 -118
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/fixTrailingNewlines.js +0 -23
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/initCatalog.js +0 -20
- invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/postExtractMessages.js +0 -36
- tests/__init__.py +0 -8
- tests/api/__init__.py +0 -8
- tests/api/conftest.py +0 -24
- tests/api/test_protect_files_rest.py +0 -73
- tests/api/test_record_api.py +0 -175
- tests/api/test_stats_api.py +0 -26
- tests/conftest.py +0 -390
- tests/fixtures/__init__.py +0 -8
- tests/fixtures/app_data/oai_sets.yaml +0 -3
- tests/fixtures/app_data/pages/about.html +0 -1
- tests/fixtures/app_data/pages.yaml +0 -4
- tests/fixtures/conftest.py +0 -27
- tests/fixtures/test_cli.py +0 -25
- tests/fixtures/test_fixtures.py +0 -46
- tests/mock_module/__init__.py +0 -7
- tests/mock_module/templates/mock_mail.html +0 -27
- tests/mock_module/views.py +0 -32
- tests/redirector/__init__.py +0 -8
- tests/redirector/conftest.py +0 -54
- tests/redirector/test_redirector.py +0 -28
- tests/test_tasks.py +0 -209
- tests/test_utils.py +0 -67
- tests/test_version.py +0 -16
- tests/test_views.py +0 -43
- tests/ui/__init__.py +0 -8
- tests/ui/conftest.py +0 -115
- tests/ui/test_deposits.py +0 -115
- tests/ui/test_export_formats.py +0 -37
- tests/ui/test_file_download.py +0 -73
- tests/ui/test_filters.py +0 -10
- tests/ui/test_robotstxt.py +0 -35
- tests/ui/test_signposting_ui.py +0 -95
- tests/ui/test_sitemaps.py +0 -85
- tests/ui/test_stats_ui.py +0 -92
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/WHEEL +0 -0
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/entry_points.txt +0 -0
- {invenio_app_rdm-13.0.0rc4.dist-info → invenio_app_rdm-13.0.0rc6.dist-info}/licenses/LICENSE +0 -0
invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/compileCatalog.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// This file is part of invenio-app-rdm.
|
|
2
|
-
// Copyright (C) 2021-2024 Graz University of Technology.
|
|
3
|
-
// Copyright (C) 2025 KTH Royal Institute of Technology.
|
|
4
|
-
//
|
|
5
|
-
// Invenio-app-rdm is free software; you can redistribute it and/or modify it
|
|
6
|
-
// under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
const { readdirSync, readFileSync, writeFileSync, existsSync } = require("fs");
|
|
9
|
-
const { gettextToI18next } = require("i18next-conv");
|
|
10
|
-
const path = require("path");
|
|
11
|
-
|
|
12
|
-
const PACKAGE_MESSAGES_PATH = "./messages";
|
|
13
|
-
const PO_FILENAME = "messages.po";
|
|
14
|
-
const JSON_FILENAME = "translations.json";
|
|
15
|
-
const GENERATED_FILE = "_generatedTranslations.js";
|
|
16
|
-
|
|
17
|
-
// it accepts the same options as the cli.
|
|
18
|
-
// https://github.com/i18next/i18next-gettext-converter#options
|
|
19
|
-
const options = {
|
|
20
|
-
/* your options here */
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
async function compileAndCreateFileForLanguage(parentPath, lang) {
|
|
24
|
-
const poFilePath = path.join(parentPath, lang, PO_FILENAME);
|
|
25
|
-
const jsonFilePath = path.join(parentPath, lang, JSON_FILENAME);
|
|
26
|
-
|
|
27
|
-
if (!existsSync(poFilePath)) {
|
|
28
|
-
console.warn(`❌ Skipping ${lang}: ${PO_FILENAME} not found.`);
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const poContent = readFileSync(poFilePath);
|
|
34
|
-
const result = await gettextToI18next(lang, poContent, options);
|
|
35
|
-
const parsed = JSON.parse(result);
|
|
36
|
-
const prettyJSON = JSON.stringify(parsed, null, 2) + "\n";
|
|
37
|
-
writeFileSync(jsonFilePath, prettyJSON);
|
|
38
|
-
console.log(`✅ Successfully converted ${lang}/${PO_FILENAME} to ${JSON_FILENAME}`);
|
|
39
|
-
return true;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error(`❌ Error processing ${lang}:`, error.message);
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function writeGeneratedTranslationsFile(languages) {
|
|
47
|
-
const generatedPath = path.join(PACKAGE_MESSAGES_PATH, GENERATED_FILE);
|
|
48
|
-
let content = "// AUTO-GENERATED FILE - DO NOT EDIT MANUALLY\n";
|
|
49
|
-
content += "// This file exports all available translations for i18next\n\n";
|
|
50
|
-
|
|
51
|
-
// Generate imports
|
|
52
|
-
languages.forEach((lang) => {
|
|
53
|
-
const varName = lang.toUpperCase().replace(/-/g, "_");
|
|
54
|
-
content += `import TRANSLATE_${varName} from "./${lang}/${JSON_FILENAME}";\n`;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Generate exports
|
|
58
|
-
content += "\nexport const translations = {\n";
|
|
59
|
-
languages.forEach((lang) => {
|
|
60
|
-
const varName = lang.toUpperCase().replace(/-/g, "_");
|
|
61
|
-
content += ` ${lang}: { translation: TRANSLATE_${varName} },\n`;
|
|
62
|
-
});
|
|
63
|
-
content += "};\n";
|
|
64
|
-
|
|
65
|
-
writeFileSync(generatedPath, content);
|
|
66
|
-
console.log(`📁 Generated translation index at ${GENERATED_FILE}`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function processAllLanguages() {
|
|
70
|
-
const directories = readdirSync(PACKAGE_MESSAGES_PATH, {
|
|
71
|
-
withFileTypes: true,
|
|
72
|
-
})
|
|
73
|
-
.filter((dir) => dir.isDirectory())
|
|
74
|
-
.map((dir) => dir.name);
|
|
75
|
-
|
|
76
|
-
const processedLangs = [];
|
|
77
|
-
for (const lang of directories) {
|
|
78
|
-
const success = await compileAndCreateFileForLanguage(PACKAGE_MESSAGES_PATH, lang);
|
|
79
|
-
if (success) processedLangs.push(lang);
|
|
80
|
-
}
|
|
81
|
-
return processedLangs;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async function handleLanguageCommand(lang) {
|
|
85
|
-
const success = await compileAndCreateFileForLanguage(PACKAGE_MESSAGES_PATH, lang);
|
|
86
|
-
if (!success) process.exit(1);
|
|
87
|
-
|
|
88
|
-
const directories = readdirSync(PACKAGE_MESSAGES_PATH, {
|
|
89
|
-
withFileTypes: true,
|
|
90
|
-
})
|
|
91
|
-
.filter((dir) => dir.isDirectory())
|
|
92
|
-
.map((dir) => dir.name);
|
|
93
|
-
|
|
94
|
-
const validLangs = directories.filter((l) =>
|
|
95
|
-
existsSync(path.join(PACKAGE_MESSAGES_PATH, l, JSON_FILENAME))
|
|
96
|
-
);
|
|
97
|
-
writeGeneratedTranslationsFile(validLangs);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Main execution flow
|
|
101
|
-
// self-executing function for coordinating async on the top level
|
|
102
|
-
// and to avoid using .then() and .catch().
|
|
103
|
-
// operations with centralized error handling.
|
|
104
|
-
(async () => {
|
|
105
|
-
try {
|
|
106
|
-
if (process.argv[2] === "lang") {
|
|
107
|
-
const lang = process.argv[3];
|
|
108
|
-
if (!lang) throw new Error("Missing language code e.g. 'sv', 'ar', etc.");
|
|
109
|
-
await handleLanguageCommand(lang);
|
|
110
|
-
} else {
|
|
111
|
-
const processedLangs = await processAllLanguages();
|
|
112
|
-
writeGeneratedTranslationsFile(processedLangs);
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error("❌ Script failed:", error.message);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
})();
|
invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/fixTrailingNewlines.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// This file is part of invenio-app-rdm.
|
|
2
|
-
// Copyright (C) 2025 CERN.
|
|
3
|
-
// Copyright (C) 2025 KTH Royal Institute of Technology.
|
|
4
|
-
//
|
|
5
|
-
// Invenio-app-rdm is free software; you can redistribute it and/or modify it
|
|
6
|
-
// under the terms of the MIT License; see LICENSE file for more details.
|
|
7
|
-
|
|
8
|
-
const fs = require("fs");
|
|
9
|
-
|
|
10
|
-
const files = ["./translations.pot", "./messages/en/messages.po"];
|
|
11
|
-
|
|
12
|
-
for (const file of files) {
|
|
13
|
-
if (!fs.existsSync(file)) {
|
|
14
|
-
console.warn(`⚠️ File not found: ${file}`);
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const content = fs.readFileSync(file, "utf8");
|
|
19
|
-
if (!content.endsWith("\n")) {
|
|
20
|
-
fs.appendFileSync(file, "\n");
|
|
21
|
-
console.log(`🔧 Appended trailing newline to: ${file}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/initCatalog.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// This file is part of invenio-app-rdm.
|
|
2
|
-
// Copyright (C) 2021 Graz University of Technology.
|
|
3
|
-
//
|
|
4
|
-
// Invenio-app-rdm is free software; you can redistribute it and/or modify it
|
|
5
|
-
// under the terms of the MIT License; see LICENSE file for more details.
|
|
6
|
-
|
|
7
|
-
const { writeFileSync } = require("fs");
|
|
8
|
-
const packageJson = require("../package");
|
|
9
|
-
|
|
10
|
-
const { languages } = packageJson.config;
|
|
11
|
-
if ("lang" === process.argv[2]) {
|
|
12
|
-
const addedLang = process.argv[3];
|
|
13
|
-
languages.push(addedLang);
|
|
14
|
-
packageJson.config.languages = [...new Set(languages)];
|
|
15
|
-
writeFileSync(`package.json`, JSON.stringify(packageJson, null, 2));
|
|
16
|
-
} else {
|
|
17
|
-
console.error(
|
|
18
|
-
"Error:Please provide a language by running `npm run init_catalog lang <lang>`"
|
|
19
|
-
);
|
|
20
|
-
}
|
invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/postExtractMessages.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// This file is part of invenio-app-rdm.
|
|
2
|
-
// Copyright (C) 2025 KTH Royal Institute of Technology.
|
|
3
|
-
//
|
|
4
|
-
// invenio-app-rdm is free software; you can redistribute it and/or modify it
|
|
5
|
-
// under the terms of the MIT License; see LICENSE file for more details.
|
|
6
|
-
|
|
7
|
-
const { execSync } = require("child_process");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Post-processing script for extracted messages
|
|
11
|
-
* Converts translations.json to .pot and .po formats and fixes trailing newlines
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const commands = [
|
|
15
|
-
// Convert to .pot format
|
|
16
|
-
"i18next-conv -l en -s ./messages/en/translations.json -t ./translations.pot",
|
|
17
|
-
// Convert to .po format
|
|
18
|
-
"i18next-conv -l en -s ./messages/en/translations.json -t ./messages/en/messages.po",
|
|
19
|
-
// Fix trailing newlines
|
|
20
|
-
"node scripts/fixTrailingNewlines.js",
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
console.log("📝 Post-processing extracted messages...");
|
|
24
|
-
|
|
25
|
-
commands.forEach((command, index) => {
|
|
26
|
-
try {
|
|
27
|
-
console.log(`⚙️ Step ${index + 1}/${commands.length}: ${command}`);
|
|
28
|
-
execSync(command, { stdio: "inherit", cwd: process.cwd() });
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(`❌ Failed to execute: ${command}`);
|
|
31
|
-
console.error(error.message);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
console.log("✅ Post-processing completed successfully!");
|
tests/__init__.py
DELETED
tests/api/__init__.py
DELETED
tests/api/conftest.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2019 CERN.
|
|
4
|
-
# Copyright (C) 2019 Northwestern University.
|
|
5
|
-
#
|
|
6
|
-
# Invenio App RDM is free software; you can redistribute it and/or modify it
|
|
7
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
8
|
-
|
|
9
|
-
"""Pytest fixtures and plugins for the API application."""
|
|
10
|
-
|
|
11
|
-
import pytest
|
|
12
|
-
from invenio_app.factory import create_api
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@pytest.fixture(scope="module")
|
|
16
|
-
def create_app():
|
|
17
|
-
"""Create test app."""
|
|
18
|
-
return create_api
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@pytest.fixture(scope="module")
|
|
22
|
-
def headers():
|
|
23
|
-
"""Return typical API headers."""
|
|
24
|
-
return {"content-type": "application/json", "accept": "application/json"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2021 CERN.
|
|
4
|
-
# Copyright (C) 2021 Northwestern University.
|
|
5
|
-
#
|
|
6
|
-
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
|
|
7
|
-
# it under the terms of the MIT License; see LICENSE file for more details.
|
|
8
|
-
|
|
9
|
-
"""Test files-rest is protected."""
|
|
10
|
-
|
|
11
|
-
from io import BytesIO
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def create_draft(client, record, headers):
|
|
15
|
-
"""Create draft and return its id."""
|
|
16
|
-
response = client.post("/records", json=record, headers=headers)
|
|
17
|
-
assert response.status_code == 201
|
|
18
|
-
return response.json["id"]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def init_file(client, recid, headers):
|
|
22
|
-
"""Init a file for draft with given recid."""
|
|
23
|
-
return client.post(
|
|
24
|
-
f"/records/{recid}/draft/files", headers=headers, json=[{"key": "test.pdf"}]
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def upload_file(client, recid):
|
|
29
|
-
"""Create draft and return its id."""
|
|
30
|
-
return client.put(
|
|
31
|
-
f"/records/{recid}/draft/files/test.pdf/content",
|
|
32
|
-
headers={
|
|
33
|
-
"content-type": "application/octet-stream",
|
|
34
|
-
"accept": "application/json",
|
|
35
|
-
},
|
|
36
|
-
data=BytesIO(b"testfile"),
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def commit_file(client, recid, headers):
|
|
41
|
-
"""Create draft and return its id."""
|
|
42
|
-
return client.post(f"/records/{recid}/draft/files/test.pdf/commit", headers=headers)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# NOTE: It seems like it was already the case that a logged in user wouldn't be
|
|
46
|
-
# able to access files-rest. We are just making doubly-clear.
|
|
47
|
-
def test_files_rest_endpoint_is_protected(
|
|
48
|
-
running_app, client_with_login, headers, es_clear, minimal_record
|
|
49
|
-
):
|
|
50
|
-
client = client_with_login
|
|
51
|
-
|
|
52
|
-
# Create draft with file
|
|
53
|
-
minimal_record["files"] = {"enabled": True}
|
|
54
|
-
recid = create_draft(client, minimal_record, headers)
|
|
55
|
-
init_file(client, recid, headers)
|
|
56
|
-
upload_file(client, recid)
|
|
57
|
-
commit_file(client, recid, headers)
|
|
58
|
-
|
|
59
|
-
# Get bucket information
|
|
60
|
-
url = f"/records/{recid}/draft/files/test.pdf"
|
|
61
|
-
response = client.get(url, headers=headers)
|
|
62
|
-
bucket_id = response.json["bucket_id"]
|
|
63
|
-
|
|
64
|
-
# Nobody is allowed to use the invenio-files-rest endpoints
|
|
65
|
-
# (even logged-in user). Just testing for the GET of each is enough
|
|
66
|
-
|
|
67
|
-
bucket_url = f"/files/{bucket_id}"
|
|
68
|
-
response = client.get(bucket_url, headers=headers)
|
|
69
|
-
assert 404 == response.status_code # because of files-rest hiding feature
|
|
70
|
-
|
|
71
|
-
bucket_key_url = f"/files/{bucket_id}/test.pdf"
|
|
72
|
-
response = client.get(bucket_key_url, headers=headers)
|
|
73
|
-
assert 404 == response.status_code
|
tests/api/test_record_api.py
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2019-2021 CERN.
|
|
4
|
-
# Copyright (C) 2019-2021 Northwestern University.
|
|
5
|
-
# Copyright (C) 2024 Graz University of Technology.
|
|
6
|
-
#
|
|
7
|
-
# Invenio-RDM-Records is free software; you can redistribute it and/or modify
|
|
8
|
-
# it under the terms of the MIT License; see LICENSE file for more details.
|
|
9
|
-
|
|
10
|
-
"""Module tests."""
|
|
11
|
-
|
|
12
|
-
import pytest
|
|
13
|
-
from invenio_pidstore.models import PersistentIdentifier
|
|
14
|
-
|
|
15
|
-
SINGLE_RECORD_API_URL = "/records/{}"
|
|
16
|
-
LIST_RECORDS_API_URL = "/records"
|
|
17
|
-
DRAFT_API_URL = "/records/{}/draft"
|
|
18
|
-
DRAFT_ACTION_API_URL = "/records/{}/draft/actions/{}"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_record_read_non_existing_pid(client, location, minimal_record, es_clear):
|
|
22
|
-
"""Retrieve a non existing record."""
|
|
23
|
-
# retrieve unknown record
|
|
24
|
-
response = client.get(SINGLE_RECORD_API_URL.format("notfound"))
|
|
25
|
-
assert response.status_code == 404
|
|
26
|
-
assert response.json["status"] == 404
|
|
27
|
-
assert response.json["message"] == "The persistent identifier does not exist."
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def test_record_draft_create_and_read(
|
|
31
|
-
client_with_login, running_app, minimal_record, es_clear
|
|
32
|
-
):
|
|
33
|
-
"""Test draft creation of a non-existing record."""
|
|
34
|
-
# create a record
|
|
35
|
-
client = client_with_login
|
|
36
|
-
response = client.post(LIST_RECORDS_API_URL, json=minimal_record)
|
|
37
|
-
|
|
38
|
-
assert response.status_code == 201
|
|
39
|
-
|
|
40
|
-
response_fields = response.json.keys()
|
|
41
|
-
fields_to_check = ["id", "metadata", "revision_id", "created", "updated", "links"]
|
|
42
|
-
|
|
43
|
-
for field in fields_to_check:
|
|
44
|
-
assert field in response_fields
|
|
45
|
-
|
|
46
|
-
recid = response.json["id"]
|
|
47
|
-
|
|
48
|
-
# retrieve record draft
|
|
49
|
-
response = client.get(DRAFT_API_URL.format(recid))
|
|
50
|
-
assert response.status_code == 200
|
|
51
|
-
assert response.json is not None
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def test_record_draft_publish(
|
|
55
|
-
client_with_login, headers, running_app, minimal_record, es_clear
|
|
56
|
-
):
|
|
57
|
-
"""Test draft publication of a non-existing record.
|
|
58
|
-
|
|
59
|
-
It has to first create said draft and includes record read.
|
|
60
|
-
"""
|
|
61
|
-
# Create the draft
|
|
62
|
-
client = client_with_login
|
|
63
|
-
response = client.post(LIST_RECORDS_API_URL, json=minimal_record, headers=headers)
|
|
64
|
-
|
|
65
|
-
assert response.status_code == 201
|
|
66
|
-
recid = response.json["id"]
|
|
67
|
-
|
|
68
|
-
# Publish it
|
|
69
|
-
response = client.post(
|
|
70
|
-
DRAFT_ACTION_API_URL.format(recid, "publish"), headers=headers
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
assert response.status_code == 202
|
|
74
|
-
response_fields = response.json.keys()
|
|
75
|
-
fields_to_check = ["id", "metadata", "revision_id", "created", "updated", "links"]
|
|
76
|
-
|
|
77
|
-
for field in fields_to_check:
|
|
78
|
-
assert field in response_fields
|
|
79
|
-
|
|
80
|
-
response = client.get(DRAFT_API_URL.format(recid), headers=headers)
|
|
81
|
-
assert response.status_code == 404
|
|
82
|
-
|
|
83
|
-
# Test record exists
|
|
84
|
-
response = client.get(SINGLE_RECORD_API_URL.format(recid), headers=headers)
|
|
85
|
-
|
|
86
|
-
assert response.status_code == 200
|
|
87
|
-
|
|
88
|
-
response_fields = response.json.keys()
|
|
89
|
-
fields_to_check = ["id", "metadata", "revision_id", "created", "updated", "links"]
|
|
90
|
-
|
|
91
|
-
for field in fields_to_check:
|
|
92
|
-
assert field in response_fields
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_read_record_with_redirected_pid(
|
|
96
|
-
client_with_login, headers, running_app, minimal_record, es_clear
|
|
97
|
-
):
|
|
98
|
-
"""Test read a record with a redirected pid."""
|
|
99
|
-
# Create dummy record
|
|
100
|
-
client = client_with_login
|
|
101
|
-
response = client.post(LIST_RECORDS_API_URL, headers=headers, json=minimal_record)
|
|
102
|
-
assert response.status_code == 201
|
|
103
|
-
# Publish it
|
|
104
|
-
pid1_value = response.json["id"]
|
|
105
|
-
response = client.post(
|
|
106
|
-
DRAFT_ACTION_API_URL.format(pid1_value, "publish"), headers=headers
|
|
107
|
-
)
|
|
108
|
-
assert response.status_code == 202
|
|
109
|
-
|
|
110
|
-
# Create another dummy record
|
|
111
|
-
response = client.post(LIST_RECORDS_API_URL, headers=headers, json=minimal_record)
|
|
112
|
-
assert response.status_code == 201
|
|
113
|
-
pid2_value = response.json["id"]
|
|
114
|
-
# Publish it
|
|
115
|
-
response = client.post(
|
|
116
|
-
DRAFT_ACTION_API_URL.format(pid2_value, "publish"), headers=headers
|
|
117
|
-
)
|
|
118
|
-
assert response.status_code == 202
|
|
119
|
-
|
|
120
|
-
# redirect pid1 to pid2
|
|
121
|
-
pid1 = PersistentIdentifier.get("recid", pid1_value)
|
|
122
|
-
pid2 = PersistentIdentifier.get("recid", pid2_value)
|
|
123
|
-
pid1.redirect(pid2)
|
|
124
|
-
|
|
125
|
-
response = client.get(SINGLE_RECORD_API_URL.format(pid1.pid_value), headers=headers)
|
|
126
|
-
assert response.status_code == 301
|
|
127
|
-
|
|
128
|
-
assert response.json["status"] == 301
|
|
129
|
-
assert response.json["message"] == "Moved Permanently."
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
@pytest.mark.skip()
|
|
133
|
-
def test_read_deleted_record(
|
|
134
|
-
client_with_login, headers, location, minimal_record, es_clear, administration_user
|
|
135
|
-
):
|
|
136
|
-
"""Test read a deleted record."""
|
|
137
|
-
client = client_with_login
|
|
138
|
-
|
|
139
|
-
# Create dummy record to test delete
|
|
140
|
-
response = client.post(LIST_RECORDS_API_URL, headers=headers, json=minimal_record)
|
|
141
|
-
assert response.status_code == 201
|
|
142
|
-
recid = response.json["id"]
|
|
143
|
-
# Publish it
|
|
144
|
-
response = client.post(
|
|
145
|
-
DRAFT_ACTION_API_URL.format(recid, "publish"), headers=headers
|
|
146
|
-
)
|
|
147
|
-
assert response.status_code == 202
|
|
148
|
-
|
|
149
|
-
# Delete the record
|
|
150
|
-
response = client.delete(SINGLE_RECORD_API_URL.format(recid), headers=headers)
|
|
151
|
-
assert response.status_code == 204
|
|
152
|
-
|
|
153
|
-
# Read the deleted record
|
|
154
|
-
response = client.get(SINGLE_RECORD_API_URL.format(recid), headers=headers)
|
|
155
|
-
assert response.status_code == 410
|
|
156
|
-
assert response.json["message"] == "The record has been deleted."
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def test_record_search(client, headers, running_app, es_clear):
|
|
160
|
-
"""Test record search."""
|
|
161
|
-
expected_response_keys = set(["hits", "links", "aggregations"])
|
|
162
|
-
expected_metadata_keys = set(["resource_type", "creators", "titles"])
|
|
163
|
-
|
|
164
|
-
# Get published bibliographic records
|
|
165
|
-
response = client.get(LIST_RECORDS_API_URL, headers=headers)
|
|
166
|
-
|
|
167
|
-
assert response.status_code == 200
|
|
168
|
-
response_keys = set(response.json.keys())
|
|
169
|
-
# The datamodel has other tests (jsonschemas, mappings, schemas)
|
|
170
|
-
# Here we just want to crosscheck the important ones are there.
|
|
171
|
-
assert expected_response_keys.issubset(response_keys)
|
|
172
|
-
|
|
173
|
-
for r in response.json["hits"]["hits"]:
|
|
174
|
-
metadata_keys = set(r["metadata"])
|
|
175
|
-
assert expected_metadata_keys.issubset(metadata_keys)
|
tests/api/test_stats_api.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Copyright (C) 2023 CERN.
|
|
4
|
-
# Copyright (C) 2024 Graz University of Technology.
|
|
5
|
-
#
|
|
6
|
-
# Invenio App RDM is free software; you can redistribute it and/or modify it
|
|
7
|
-
# under the terms of the MIT License; see LICENSE file for more details.
|
|
8
|
-
|
|
9
|
-
"""Test the statistics integration."""
|
|
10
|
-
|
|
11
|
-
from invenio_accounts.testutils import login_user_via_session
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def test_ui_event_emission(running_app, headers, client, administration_user):
|
|
15
|
-
"""It is expected that the REST API endpoint for the statistics is disabled."""
|
|
16
|
-
login_user_via_session(client, email=administration_user.email)
|
|
17
|
-
|
|
18
|
-
# NOTE: the permissions are only relevant per requested query type ("stat")
|
|
19
|
-
data = {"my-query": {"stat": "record-view", "params": {"recid": "doesnt-matter"}}}
|
|
20
|
-
result = client.post("/stats", headers=headers, json=data)
|
|
21
|
-
assert result.status_code == 403
|
|
22
|
-
|
|
23
|
-
# i.e. if no queries are requested, nothing will be denied
|
|
24
|
-
result = client.post("/stats", headers=headers, json={})
|
|
25
|
-
assert result.status_code == 200
|
|
26
|
-
assert result.json == {}
|