rara-tools 0.0.8__tar.gz → 0.0.9__tar.gz

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.

Potentially problematic release.


This version of rara-tools might be problematic. Click here for more details.

Files changed (27) hide show
  1. {rara_tools-0.0.8/rara_tools.egg-info → rara_tools-0.0.9}/PKG-INFO +32 -18
  2. {rara_tools-0.0.8 → rara_tools-0.0.9}/README.md +31 -17
  3. rara_tools-0.0.9/VERSION +1 -0
  4. rara_tools-0.0.9/rara_tools/converters.py +41 -0
  5. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/decorators.py +3 -3
  6. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/elastic.py +1 -1
  7. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/exceptions.py +3 -0
  8. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/s3.py +3 -2
  9. {rara_tools-0.0.8 → rara_tools-0.0.9/rara_tools.egg-info}/PKG-INFO +32 -18
  10. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools.egg-info/SOURCES.txt +2 -0
  11. rara_tools-0.0.9/tests/test_converters.py +105 -0
  12. {rara_tools-0.0.8 → rara_tools-0.0.9}/tests/test_elastic.py +0 -1
  13. {rara_tools-0.0.8 → rara_tools-0.0.9}/tests/test_s3_exceptions.py +4 -3
  14. {rara_tools-0.0.8 → rara_tools-0.0.9}/tests/test_task_reporter.py +1 -0
  15. rara_tools-0.0.8/VERSION +0 -1
  16. {rara_tools-0.0.8 → rara_tools-0.0.9}/LICENSE.md +0 -0
  17. {rara_tools-0.0.8 → rara_tools-0.0.9}/pyproject.toml +0 -0
  18. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/constants/__init__.py +0 -0
  19. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/constants/digitizer.py +0 -0
  20. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/constants/general.py +0 -0
  21. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools/task_reporter.py +0 -0
  22. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools.egg-info/dependency_links.txt +0 -0
  23. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools.egg-info/requires.txt +0 -0
  24. {rara_tools-0.0.8 → rara_tools-0.0.9}/rara_tools.egg-info/top_level.txt +0 -0
  25. {rara_tools-0.0.8 → rara_tools-0.0.9}/requirements.txt +0 -0
  26. {rara_tools-0.0.8 → rara_tools-0.0.9}/setup.cfg +0 -0
  27. {rara_tools-0.0.8 → rara_tools-0.0.9}/tests/test_s3_file_operations.py +1 -1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rara-tools
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Tools to support Kata's work.
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -28,25 +28,28 @@ Requires-Dist: pytest-order; extra == "testing"
28
28
 
29
29
  ---
30
30
 
31
- ## ✨ Features
31
+ ## ✨ Features
32
32
 
33
33
  - Elasticsearch index & document operations
34
34
  - S3 file management operations
35
35
  - Task reporting to Core API
36
+ - Converting SIERRA API responses to Pymarc compatible JSON
37
+
36
38
  ---
37
39
 
38
- ## ⚡ Quick Start
40
+ ## ⚡ Quick Start
39
41
 
40
42
  Get started with `rara-tools` in just a few steps:
41
43
 
42
44
  1. **Install the Package**
43
- Ensure you're using Python 3.10 or above, then run:
45
+ Ensure you're using Python 3.10 or above, then run:
46
+
44
47
  ```bash
45
48
  pip install rara-tools
46
49
  ```
47
50
 
48
51
  2. **Import and Use**
49
- Example usage to download a folder from S3:
52
+ Example usage to download a folder from S3:
50
53
 
51
54
  ```python
52
55
  from rara_tools.s3 import S3Files
@@ -77,22 +80,25 @@ Follow the steps below to install the `rara-tools` package, either via `pip` or
77
80
  Create or activate a Python environment using Python **3.10** or above.
78
81
 
79
82
  2. **Install the Package**
80
- Run the following command:
83
+ Run the following command:
84
+
81
85
  ```bash
82
86
  pip install rara-tools
83
87
  ```
84
- </details>
88
+
89
+ </details>
85
90
 
86
91
  ---
87
92
 
88
93
  ### Local Installation
89
94
 
90
- Follow these steps to install the `rara-tools` package locally:
95
+ Follow these steps to install the `rara-tools` package locally:
91
96
 
92
97
  <details><summary>Click to expand</summary>
93
98
 
94
99
  1. **Clone the Repository**
95
- Clone the repository and navigate into it:
100
+ Clone the repository and navigate into it:
101
+
96
102
  ```bash
97
103
  git clone <repository-url>
98
104
  cd <repository-directory>
@@ -100,25 +106,29 @@ Follow these steps to install the `rara-tools` package locally:
100
106
 
101
107
  2. **Set Up Python Environment**
102
108
  Create or activate a Python environment using Python 3.10 or above. E.g:
109
+
103
110
  ```bash
104
111
  conda create -n py310 python==3.10
105
112
  conda activate py310
106
113
  ```
107
114
 
108
115
  3. **Install Build Package**
109
- Install the `build` package to enable local builds:
116
+ Install the `build` package to enable local builds:
117
+
110
118
  ```bash
111
119
  pip install build
112
120
  ```
113
121
 
114
122
  4. **Build the Package**
115
- Run the following command inside the repository:
123
+ Run the following command inside the repository:
124
+
116
125
  ```bash
117
126
  python -m build
118
127
  ```
119
128
 
120
129
  5. **Install the Package**
121
- Install the built package locally:
130
+ Install the built package locally:
131
+
122
132
  ```bash
123
133
  pip install .
124
134
  ```
@@ -131,13 +141,13 @@ Follow these steps to install the `rara-tools` package locally:
131
141
 
132
142
  Follow these steps to test the `rara-tools` package.
133
143
 
134
-
135
144
  ### How to Test
136
145
 
137
146
  <details><summary>Click to expand</summary>
138
147
 
139
148
  1. **Clone the Repository**
140
- Clone the repository and navigate into it:
149
+ Clone the repository and navigate into it:
150
+
141
151
  ```bash
142
152
  git clone <repository-url>
143
153
  cd <repository-directory>
@@ -147,25 +157,29 @@ Follow these steps to test the `rara-tools` package.
147
157
  Create or activate a Python environment using Python 3.10 or above.
148
158
 
149
159
  3. **Install Build Package**
150
- Install the `build` package:
160
+ Install the `build` package:
161
+
151
162
  ```bash
152
163
  pip install build
153
164
  ```
154
165
 
155
166
  4. **Build the Package**
156
- Build the package inside the repository:
167
+ Build the package inside the repository:
168
+
157
169
  ```bash
158
170
  python -m build
159
171
  ```
160
172
 
161
173
  5. **Install with Testing Dependencies**
162
- Install the package along with its testing dependencies:
174
+ Install the package along with its testing dependencies:
175
+
163
176
  ```bash
164
177
  pip install .[testing]
165
178
  ```
166
179
 
167
180
  6. **Run Tests**
168
- Run the test suite from the repository root:
181
+ Run the test suite from the repository root:
182
+
169
183
  ```bash
170
184
  python -m pytest -v tests
171
185
  ```
@@ -8,25 +8,28 @@
8
8
 
9
9
  ---
10
10
 
11
- ## ✨ Features
11
+ ## ✨ Features
12
12
 
13
13
  - Elasticsearch index & document operations
14
14
  - S3 file management operations
15
15
  - Task reporting to Core API
16
+ - Converting SIERRA API responses to Pymarc compatible JSON
17
+
16
18
  ---
17
19
 
18
- ## ⚡ Quick Start
20
+ ## ⚡ Quick Start
19
21
 
20
22
  Get started with `rara-tools` in just a few steps:
21
23
 
22
24
  1. **Install the Package**
23
- Ensure you're using Python 3.10 or above, then run:
25
+ Ensure you're using Python 3.10 or above, then run:
26
+
24
27
  ```bash
25
28
  pip install rara-tools
26
29
  ```
27
30
 
28
31
  2. **Import and Use**
29
- Example usage to download a folder from S3:
32
+ Example usage to download a folder from S3:
30
33
 
31
34
  ```python
32
35
  from rara_tools.s3 import S3Files
@@ -57,22 +60,25 @@ Follow the steps below to install the `rara-tools` package, either via `pip` or
57
60
  Create or activate a Python environment using Python **3.10** or above.
58
61
 
59
62
  2. **Install the Package**
60
- Run the following command:
63
+ Run the following command:
64
+
61
65
  ```bash
62
66
  pip install rara-tools
63
67
  ```
64
- </details>
68
+
69
+ </details>
65
70
 
66
71
  ---
67
72
 
68
73
  ### Local Installation
69
74
 
70
- Follow these steps to install the `rara-tools` package locally:
75
+ Follow these steps to install the `rara-tools` package locally:
71
76
 
72
77
  <details><summary>Click to expand</summary>
73
78
 
74
79
  1. **Clone the Repository**
75
- Clone the repository and navigate into it:
80
+ Clone the repository and navigate into it:
81
+
76
82
  ```bash
77
83
  git clone <repository-url>
78
84
  cd <repository-directory>
@@ -80,25 +86,29 @@ Follow these steps to install the `rara-tools` package locally:
80
86
 
81
87
  2. **Set Up Python Environment**
82
88
  Create or activate a Python environment using Python 3.10 or above. E.g:
89
+
83
90
  ```bash
84
91
  conda create -n py310 python==3.10
85
92
  conda activate py310
86
93
  ```
87
94
 
88
95
  3. **Install Build Package**
89
- Install the `build` package to enable local builds:
96
+ Install the `build` package to enable local builds:
97
+
90
98
  ```bash
91
99
  pip install build
92
100
  ```
93
101
 
94
102
  4. **Build the Package**
95
- Run the following command inside the repository:
103
+ Run the following command inside the repository:
104
+
96
105
  ```bash
97
106
  python -m build
98
107
  ```
99
108
 
100
109
  5. **Install the Package**
101
- Install the built package locally:
110
+ Install the built package locally:
111
+
102
112
  ```bash
103
113
  pip install .
104
114
  ```
@@ -111,13 +121,13 @@ Follow these steps to install the `rara-tools` package locally:
111
121
 
112
122
  Follow these steps to test the `rara-tools` package.
113
123
 
114
-
115
124
  ### How to Test
116
125
 
117
126
  <details><summary>Click to expand</summary>
118
127
 
119
128
  1. **Clone the Repository**
120
- Clone the repository and navigate into it:
129
+ Clone the repository and navigate into it:
130
+
121
131
  ```bash
122
132
  git clone <repository-url>
123
133
  cd <repository-directory>
@@ -127,25 +137,29 @@ Follow these steps to test the `rara-tools` package.
127
137
  Create or activate a Python environment using Python 3.10 or above.
128
138
 
129
139
  3. **Install Build Package**
130
- Install the `build` package:
140
+ Install the `build` package:
141
+
131
142
  ```bash
132
143
  pip install build
133
144
  ```
134
145
 
135
146
  4. **Build the Package**
136
- Build the package inside the repository:
147
+ Build the package inside the repository:
148
+
137
149
  ```bash
138
150
  python -m build
139
151
  ```
140
152
 
141
153
  5. **Install with Testing Dependencies**
142
- Install the package along with its testing dependencies:
154
+ Install the package along with its testing dependencies:
155
+
143
156
  ```bash
144
157
  pip install .[testing]
145
158
  ```
146
159
 
147
160
  6. **Run Tests**
148
- Run the test suite from the repository root:
161
+ Run the test suite from the repository root:
162
+
149
163
  ```bash
150
164
  python -m pytest -v tests
151
165
  ```
@@ -0,0 +1 @@
1
+ 0.0.9
@@ -0,0 +1,41 @@
1
+ from .exceptions import SierraResponseConverterException
2
+
3
+
4
+ class SierraResponseConverter:
5
+ """ Takes a JSON response from the Sierra API (https://tester.ester.ee/iii/sierra-api/swagger/index.html)
6
+ and converts it to MARC-in-JSON format.
7
+
8
+ """
9
+
10
+ def __init__(self, response: dict):
11
+ if not isinstance(response, dict):
12
+ raise SierraResponseConverterException("Please provide a valid JSON response.")
13
+ self.response = response
14
+
15
+ def _map_field_data(self, field):
16
+ tag = field.get("tag")
17
+ if not tag:
18
+ raise SierraResponseConverterException("Field is missing a valid 'tag'.")
19
+ data = field.get("data", {})
20
+ return {tag: data}
21
+
22
+ def _convert_response(self):
23
+ response = self.response
24
+
25
+ entries = response.get("entries")
26
+ if not entries:
27
+ raise SierraResponseConverterException("No entries found in the response.")
28
+
29
+ try:
30
+ fields = [self._map_field_data(f) for e in entries for f in e["marc"]["fields"]]
31
+ except KeyError as e:
32
+ raise SierraResponseConverterException(f"Missing expected MARC fields in the response: {e}")
33
+
34
+ return {"fields": fields}
35
+
36
+ def convert(self):
37
+ """Runner method, converts the response to MARC-in-JSON format with error handling."""
38
+ try:
39
+ return self._convert_response()
40
+ except Exception as e:
41
+ raise SierraResponseConverterException(f"An unexpected error occurred during conversion: {e}")
@@ -1,12 +1,12 @@
1
1
  import functools
2
+ from typing import Any, Callable
3
+
2
4
  from elasticsearch import AuthenticationException
3
5
  from elasticsearch import ConnectionError as ElasticsearchConnectionError
4
6
  from elasticsearch import ConnectionTimeout, NotFoundError, RequestError
5
- from typing import Any, Callable
6
7
 
7
8
  from .exceptions import ElasticsearchException
8
9
 
9
-
10
10
  ELASTIC_NOT_FOUND_MESSAGE = 'Could not find specified data from Elasticsearch!'
11
11
  ELASTIC_REQUEST_ERROR_MESSAGE = 'Error executing Elasticsearch query! Bad query?'
12
12
  ELASTIC_CONNECTION_TIMEOUT_MESSAGE = 'Connection to Elasticsearch took too long, please try again later!'
@@ -39,4 +39,4 @@ def _elastic_connection(func: Callable) -> Callable:
39
39
  raise ElasticsearchException(ELASTIC_CONNECTION_ERROR_MESSAGE) from exception
40
40
  except Exception as exception:
41
41
  raise ElasticsearchException(ELASTIC_UNKNOWN_ERROR_MESSAGE) from exception
42
- return wrapper
42
+ return wrapper
@@ -1,4 +1,4 @@
1
- from typing import Dict, Optional, Any, Iterator
1
+ from typing import Any, Dict, Iterator, Optional
2
2
 
3
3
  import elasticsearch_dsl
4
4
  from elastic_transport import ObjectApiResponse
@@ -12,3 +12,6 @@ class ElasticsearchException(Exception):
12
12
 
13
13
  class TaskReporterException(Exception):
14
14
  """Raised TaskReporter Error."""
15
+
16
+ class SierraResponseConverterException(Exception):
17
+ """Raised SierraResponseConverter Error."""
@@ -1,10 +1,11 @@
1
1
  import os
2
2
  import uuid
3
- from typing import Optional, List, Generator, Any
3
+ from typing import Any, Generator, List, Optional
4
4
 
5
5
  from minio import Minio
6
6
 
7
- from .exceptions import S3InitException, S3ConnectionException, S3InputException
7
+ from .exceptions import (S3ConnectionException, S3InitException,
8
+ S3InputException)
8
9
 
9
10
 
10
11
  class S3Files:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: rara-tools
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: Tools to support Kata's work.
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -28,25 +28,28 @@ Requires-Dist: pytest-order; extra == "testing"
28
28
 
29
29
  ---
30
30
 
31
- ## ✨ Features
31
+ ## ✨ Features
32
32
 
33
33
  - Elasticsearch index & document operations
34
34
  - S3 file management operations
35
35
  - Task reporting to Core API
36
+ - Converting SIERRA API responses to Pymarc compatible JSON
37
+
36
38
  ---
37
39
 
38
- ## ⚡ Quick Start
40
+ ## ⚡ Quick Start
39
41
 
40
42
  Get started with `rara-tools` in just a few steps:
41
43
 
42
44
  1. **Install the Package**
43
- Ensure you're using Python 3.10 or above, then run:
45
+ Ensure you're using Python 3.10 or above, then run:
46
+
44
47
  ```bash
45
48
  pip install rara-tools
46
49
  ```
47
50
 
48
51
  2. **Import and Use**
49
- Example usage to download a folder from S3:
52
+ Example usage to download a folder from S3:
50
53
 
51
54
  ```python
52
55
  from rara_tools.s3 import S3Files
@@ -77,22 +80,25 @@ Follow the steps below to install the `rara-tools` package, either via `pip` or
77
80
  Create or activate a Python environment using Python **3.10** or above.
78
81
 
79
82
  2. **Install the Package**
80
- Run the following command:
83
+ Run the following command:
84
+
81
85
  ```bash
82
86
  pip install rara-tools
83
87
  ```
84
- </details>
88
+
89
+ </details>
85
90
 
86
91
  ---
87
92
 
88
93
  ### Local Installation
89
94
 
90
- Follow these steps to install the `rara-tools` package locally:
95
+ Follow these steps to install the `rara-tools` package locally:
91
96
 
92
97
  <details><summary>Click to expand</summary>
93
98
 
94
99
  1. **Clone the Repository**
95
- Clone the repository and navigate into it:
100
+ Clone the repository and navigate into it:
101
+
96
102
  ```bash
97
103
  git clone <repository-url>
98
104
  cd <repository-directory>
@@ -100,25 +106,29 @@ Follow these steps to install the `rara-tools` package locally:
100
106
 
101
107
  2. **Set Up Python Environment**
102
108
  Create or activate a Python environment using Python 3.10 or above. E.g:
109
+
103
110
  ```bash
104
111
  conda create -n py310 python==3.10
105
112
  conda activate py310
106
113
  ```
107
114
 
108
115
  3. **Install Build Package**
109
- Install the `build` package to enable local builds:
116
+ Install the `build` package to enable local builds:
117
+
110
118
  ```bash
111
119
  pip install build
112
120
  ```
113
121
 
114
122
  4. **Build the Package**
115
- Run the following command inside the repository:
123
+ Run the following command inside the repository:
124
+
116
125
  ```bash
117
126
  python -m build
118
127
  ```
119
128
 
120
129
  5. **Install the Package**
121
- Install the built package locally:
130
+ Install the built package locally:
131
+
122
132
  ```bash
123
133
  pip install .
124
134
  ```
@@ -131,13 +141,13 @@ Follow these steps to install the `rara-tools` package locally:
131
141
 
132
142
  Follow these steps to test the `rara-tools` package.
133
143
 
134
-
135
144
  ### How to Test
136
145
 
137
146
  <details><summary>Click to expand</summary>
138
147
 
139
148
  1. **Clone the Repository**
140
- Clone the repository and navigate into it:
149
+ Clone the repository and navigate into it:
150
+
141
151
  ```bash
142
152
  git clone <repository-url>
143
153
  cd <repository-directory>
@@ -147,25 +157,29 @@ Follow these steps to test the `rara-tools` package.
147
157
  Create or activate a Python environment using Python 3.10 or above.
148
158
 
149
159
  3. **Install Build Package**
150
- Install the `build` package:
160
+ Install the `build` package:
161
+
151
162
  ```bash
152
163
  pip install build
153
164
  ```
154
165
 
155
166
  4. **Build the Package**
156
- Build the package inside the repository:
167
+ Build the package inside the repository:
168
+
157
169
  ```bash
158
170
  python -m build
159
171
  ```
160
172
 
161
173
  5. **Install with Testing Dependencies**
162
- Install the package along with its testing dependencies:
174
+ Install the package along with its testing dependencies:
175
+
163
176
  ```bash
164
177
  pip install .[testing]
165
178
  ```
166
179
 
167
180
  6. **Run Tests**
168
- Run the test suite from the repository root:
181
+ Run the test suite from the repository root:
182
+
169
183
  ```bash
170
184
  python -m pytest -v tests
171
185
  ```
@@ -3,6 +3,7 @@ README.md
3
3
  VERSION
4
4
  pyproject.toml
5
5
  requirements.txt
6
+ rara_tools/converters.py
6
7
  rara_tools/decorators.py
7
8
  rara_tools/elastic.py
8
9
  rara_tools/exceptions.py
@@ -16,6 +17,7 @@ rara_tools.egg-info/top_level.txt
16
17
  rara_tools/constants/__init__.py
17
18
  rara_tools/constants/digitizer.py
18
19
  rara_tools/constants/general.py
20
+ tests/test_converters.py
19
21
  tests/test_elastic.py
20
22
  tests/test_s3_exceptions.py
21
23
  tests/test_s3_file_operations.py
@@ -0,0 +1,105 @@
1
+ import json
2
+ import os
3
+
4
+ import pytest
5
+ from rara_tools.converters import SierraResponseConverter
6
+ from rara_tools.exceptions import SierraResponseConverterException
7
+
8
+ root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9
+
10
+ SIERRA_TEST_DATA_DIR = os.path.join(root, "tests", "test_data", "sierra")
11
+ INPUT_DIR = os.path.join(SIERRA_TEST_DATA_DIR, "input")
12
+ OUTPUT_DIR = os.path.join(SIERRA_TEST_DATA_DIR, "output")
13
+
14
+ example_res = {
15
+ "total": 100,
16
+ "start": 50000,
17
+ "entries": [
18
+ {
19
+ "id": 1126963,
20
+ "updatedDate": "2016-02-09T08:42:52Z",
21
+ "createdDate": "2014-05-17T17:22:00Z",
22
+ "deleted": False,
23
+ "suppressed": False,
24
+ "marc": {
25
+ "leader": "00000nz a2200145n 4500",
26
+ "fields": [
27
+ {
28
+ # "tag": "100",
29
+ "data": {
30
+ "subfields": [
31
+ {
32
+ "code": "a",
33
+ "data": "Viggor, Signe,"
34
+ },
35
+ {
36
+ "code": "d",
37
+ "data": "1975-"
38
+ }
39
+ ],
40
+ "ind1": "1",
41
+ "ind2": " "
42
+ }
43
+ },
44
+ ]}}]}
45
+
46
+
47
+ def read_json_file(file_path):
48
+ with open(file_path, "r") as f:
49
+ data = f.read()
50
+ return json.loads(data)
51
+
52
+ def test_convert_bibs_response():
53
+ response = read_json_file(os.path.join(INPUT_DIR, "bibs.json"))
54
+
55
+ converter = SierraResponseConverter(response)
56
+ data = converter.convert()
57
+
58
+ expected = read_json_file(os.path.join(OUTPUT_DIR, "bibs.json"))
59
+ assert data == expected
60
+
61
+
62
+ def test_convert_keywords_response():
63
+ with open(os.path.join(INPUT_DIR, "keywords.json"), "r") as f:
64
+ response = f.read()
65
+ response = json.loads(response)
66
+
67
+ converter = SierraResponseConverter(response)
68
+ data = converter.convert()
69
+
70
+ expected = read_json_file(os.path.join(OUTPUT_DIR, "keywords.json"))
71
+
72
+ assert data == expected
73
+
74
+
75
+ def test_convert_authorities_response():
76
+ with open(os.path.join(INPUT_DIR, "authorities.json"), "r") as f:
77
+ response = f.read()
78
+ response = json.loads(response)
79
+
80
+ converter = SierraResponseConverter(response)
81
+ data = converter.convert()
82
+
83
+ expected = read_json_file(os.path.join(OUTPUT_DIR, "authorities.json"))
84
+
85
+ assert data == expected
86
+
87
+ def test_convert_with_wrong_format():
88
+ with pytest.raises(SierraResponseConverterException):
89
+ SierraResponseConverter("$")
90
+
91
+ def test_convert_missing_tag():
92
+ with pytest.raises(SierraResponseConverterException):
93
+ response = example_res.copy()
94
+ response["entries"][0]["marc"]["fields"][0].pop("tag", None)
95
+
96
+ converter = SierraResponseConverter(response)
97
+ converter.convert()
98
+
99
+ def test_no_entries_in_response():
100
+ with pytest.raises(SierraResponseConverterException):
101
+ response = example_res.copy()
102
+ response.pop("entries", [])
103
+
104
+ converter = SierraResponseConverter(response)
105
+ converter.convert()
@@ -5,7 +5,6 @@ import uuid
5
5
  from time import sleep
6
6
 
7
7
  import pytest
8
-
9
8
  from rara_tools.elastic import KataElastic
10
9
 
11
10
  with open("./tests/test_data/elastic_docs.json") as fh:
@@ -1,8 +1,9 @@
1
- import pytest
2
1
  import os
3
- from rara_tools.s3 import S3Files
4
- from rara_tools.exceptions import S3InitException, S3ConnectionException, S3InputException
5
2
 
3
+ import pytest
4
+ from rara_tools.exceptions import (S3ConnectionException, S3InitException,
5
+ S3InputException)
6
+ from rara_tools.s3 import S3Files
6
7
 
7
8
  TEST_URL = os.getenv("S3_URL", "s3.eu-central-003.backblazeb2.com")
8
9
  TEST_ACCESS_KEY = os.getenv("S3_ACCESS_KEY", "")
@@ -1,4 +1,5 @@
1
1
  import os
2
+
2
3
  from rara_tools.task_reporter import TaskReporter
3
4
 
4
5
  REPORTER = TaskReporter(
rara_tools-0.0.8/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.8
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
- import pytest
2
1
  import os
3
2
 
3
+ import pytest
4
4
  from rara_tools.s3 import S3Files
5
5
 
6
6
  S3_FILES = S3Files(