Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
push:
branches:
- master
- develop
pull_request:

jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
run: |
python -m unittest \
thothlibrary.tests.test_rest \
thothlibrary.thoth-1_0_0.tests.tests
31 changes: 1 addition & 30 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
Most components released under the Apache License.

Modified GraphQL client released under the MIT License.


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -191,7 +186,7 @@ Modified GraphQL client released under the MIT License.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 Open Book Publishers
Copyright 2026 Thoth Open Metadata

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -204,27 +199,3 @@ Modified GraphQL client released under the MIT License.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



The MIT License (MIT)

Copyright (c) 2016 graph.cool

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Python client for Thoth's GraphQL and REST APIs. Currently supports Thoth version 0.6.0.
Python client for Thoth's APIs. This release supports the Thoth `1.0.0` GraphQL schema and uses personal access tokens for authenticated GraphQL requests.

[![Release](https://img.shields.io/github/release/openbookpublishers/thoth-client.svg?colorB=58839b)](https://github.com/openbookpublishers/thoth-client/releases) [![PyPi version](https://badgen.net/pypi/v/thothlibrary/)](https://pypi.org/project/thothlibrary)

Expand All @@ -9,7 +9,7 @@ Install is either via pip or cloning the repository.

From pip:
```sh
python3 -m pip install thothlibrary==0.31.0
python3 -m pip install thothlibrary==1.0.0
```

Or from the repo:
Expand All @@ -24,10 +24,13 @@ pip3 install -r ./requirements.txt
from thothlibrary import ThothClient

thoth = ThothClient()
thoth.set_token("your-pat")
print(thoth.works())
```

### CLI GraphQL Usage
Set `THOTH_PAT` for authenticated commands such as mutations.

```sh
python3 -m thothlibrary.cli contribution --contribution_id=29e4f46b-851a-4d7b-bb41-e6f305fc2b11
python3 -m thothlibrary.cli contributions --limit=10
Expand Down Expand Up @@ -83,29 +86,11 @@ print(client.formats())

### CLI REST Usage
```sh
python3 -m thothrest.cli
python3 -m thothrest.cli formats
python3 -m thothrest.cli formats --return-json
python3 -m thothrest.cli work onix_3.0::project_muse e0f748b2-984f-45cc-8b9e-13989c31dda4
python3 -m thothlibrary.rest_cli formats
python3 -m thothlibrary.rest_cli formats --return_json
python3 -m thothlibrary.rest_cli work onix_3.0::project_muse e0f748b2-984f-45cc-8b9e-13989c31dda4
```

## Thoth Django
The thothdjango folder includes models, an import routine, subject-code support, and admin procedures to use Thoth in a django app. The import provides unidirectional synchronization from remote Thoth imports to a local database for use in a Django app.

## Test Suite
Tests for GraphQL queries are versioned in the thoth-[ver] folder of thothlibrary.

Tests confirm that current code produces good, known object outputs from stored GraphQL input.

## Versioning
The Thoth API is not yet considered stable and functionality changes between versions. The recommended way to add a new version compatibility is:

1. Read the latest Thoth changelog to understand the changes.
2. Copy the latest thoth-[ver] folder to the correctly named new version.
3. Find and replace the strings specified in genfixtures.sh and genjson.sh. Update the version string in tests and endpoints.
4. Run genjson.sh _only_ from inside the tests directory of the new version. This will fetch the latest server JSON responses and store it inside the fixtures directory for these tests. If there are any errors, then the command line CLI has encountered a breaking change that must first be fixed.
5. Run the test suite for the latest version and examine breakages. It is possible that breakages are not actually full breakdown, but merely a change in the serialized object. Nonetheless, fix these by subclassing the previous versions of the API and overriding broken methods. In the cases of total breakage, a non-subclassed rewrite may be more appropriate. (May also apply at major version breaks.)
6. When the test suite passes, or a new object format has been decided and tests rewritten, run genfixtures.sh to freeze the current test suite.
7. Include the new version directory in the list of packages in `setup.py`
8. Update `THOTH_VERSION` in `thothlibrary/client.py`

The GraphQL test suite is focused on the retained `1.0.0` client surface under `thothlibrary/thoth-1_0_0/tests`.
The export API client is covered by focused tests under `thothlibrary/tests`.
11 changes: 2 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@
url="https://github.com/thoth-pub/thoth-client",
packages=[
"thothlibrary",
"thothrest",
"thothdjango",
"thothlibrary.thoth-0_4_2",
"thothrest.thoth-0_4_2",
"thothlibrary.thoth-0_5_0",
"thothlibrary.thoth-0_6_0",
"thothlibrary.thoth-0_8_0",
"thothlibrary.thoth-0_8_4",
"thothlibrary.thoth-0_9_0"
"thothlibrary.tests",
"thothlibrary.thoth-1_0_0",
],
include_package_data=True,
install_requires=[
Expand Down
71 changes: 0 additions & 71 deletions thothdjango/admin.py

This file was deleted.

Empty file.
29 changes: 0 additions & 29 deletions thothdjango/management/commands/fetch_ROR.py

This file was deleted.

52 changes: 0 additions & 52 deletions thothdjango/management/commands/install_bic.py

This file was deleted.

43 changes: 0 additions & 43 deletions thothdjango/management/commands/install_bisac.py

This file was deleted.

Loading
Loading