Skip to content

Commit 48d836a

Browse files
committed
Add runner invenio install/setup
1 parent 05b36dc commit 48d836a

3 files changed

Lines changed: 120 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build and Install
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: |
25+
3.10.19
26+
3.9
27+
28+
- name: Set up Docker Compose
29+
uses: docker/setup-compose-action@v1
30+
31+
# Building mandb triggers take 45s+ for no benefit (we don't use man in CI)
32+
- name: Disable mandb
33+
run: |
34+
echo "set man-db/auto-update false" | sudo debconf-communicate
35+
sudo dpkg-reconfigure man-db
36+
37+
- name: Setup Invenio deps
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install libcairo2-dev fonts-dejavu imagemagick
41+
pip install --upgrade pip pipfile
42+
pip install invenio-cli click
43+
44+
- name: Setup Invenio
45+
run: |
46+
invenio-cli check-requirements
47+
yes "" | invenio-cli init rdm # (choose defaults as test)
48+
49+
- name: start invenio
50+
run: |
51+
invenio-cli install all
52+
invenio-cli services setup
53+
invenio-cli services start
54+
invenio-cli run all &
55+
echo "Starting:"
56+
invenio --help
57+
invenio tokens --help
58+
invenio tokens create --help
59+
exit 1
60+
working-directory: my-site
61+
62+
- uses: actions/checkout@v4
63+
- name: Install dependencies
64+
run: |
65+
/opt/hostedtoolcache/Python/3.10.19/x64/python -m pip install setuptools build
66+
67+
- name: Install
68+
run: |
69+
/opt/hostedtoolcache/Python/3.10.19/x64/python -m pip install ".[test]"
70+
71+
- name: Run Tests
72+
run: |
73+
/opt/hostedtoolcache/Python/3.10.19/x64/python -m pytest --doctest-modules

data_collections_api/invenio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ class InvenioRepository:
11151115
11161116
my_repo = InvenioRepository(url="companyname.website", api_key="abc123")
11171117
my_repo.depositions["my_repo"].files["file"].upload(my_file)
1118-
my_repo.records.get()
1118+
my_repo.depositions.get()
11191119
my_repo.licenses.list()
11201120
"""
11211121

tests/test_send.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""Test repository API functions."""
2+
3+
from __future__ import annotations
4+
5+
from pathlib import Path
6+
7+
import pytest
8+
9+
from data_collections_api.dumpers import get_loader
10+
from data_collections_api.invenio import InvenioRepository
11+
12+
LOCAL_SERVER = "127.0.0.1"
13+
LOCAL_PORT = "5000"
14+
15+
DATA_DIR = Path(__file__).parent / "test_data"
16+
17+
18+
@pytest.fixture
19+
def repo():
20+
return InvenioRepository(url=f"http://{LOCAL_SERVER}:{LOCAL_PORT}", api_key="")
21+
22+
23+
def test_create_depo(repo):
24+
# create an empty draft record in Invenio and retrieve its id
25+
draft = repo.depositions.create()
26+
draft_id = draft.get()["id"]
27+
28+
print(draft_id)
29+
30+
metadata_path = DATA_DIR / "bare_example.yml"
31+
32+
# open metadata record
33+
loader = get_loader("yaml")
34+
data = loader(metadata_path)
35+
36+
# add metadata to draft
37+
repo.depositions.draft(draft_id).update(data)
38+
39+
# add files to draft
40+
repo.depositions.draft(draft_id).files.upload({"metadata": metadata_path})
41+
42+
# bind draft to a community
43+
repo.depositions.draft(draft_id).bind("geoff")
44+
45+
# submit draft for review
46+
repo.depositions.draft(draft_id).submit_review()

0 commit comments

Comments
 (0)