rara-tools 0.0.1__tar.gz → 0.0.2__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 (25) hide show
  1. rara_tools-0.0.2/PKG-INFO +175 -0
  2. rara_tools-0.0.2/README.md +155 -0
  3. rara_tools-0.0.2/VERSION +1 -0
  4. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools/elastic.py +12 -9
  5. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools/s3.py +10 -8
  6. rara_tools-0.0.2/rara_tools.egg-info/PKG-INFO +175 -0
  7. {rara_tools-0.0.1 → rara_tools-0.0.2}/tests/test_elastic.py +15 -1
  8. rara_tools-0.0.1/PKG-INFO +0 -21
  9. rara_tools-0.0.1/README.md +0 -1
  10. rara_tools-0.0.1/VERSION +0 -1
  11. rara_tools-0.0.1/rara_tools.egg-info/PKG-INFO +0 -21
  12. {rara_tools-0.0.1 → rara_tools-0.0.2}/LICENSE.md +0 -0
  13. {rara_tools-0.0.1 → rara_tools-0.0.2}/pyproject.toml +0 -0
  14. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools/decorators.py +0 -0
  15. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools/exceptions.py +0 -0
  16. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools/task_reporter.py +0 -0
  17. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools.egg-info/SOURCES.txt +0 -0
  18. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools.egg-info/dependency_links.txt +0 -0
  19. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools.egg-info/requires.txt +0 -0
  20. {rara_tools-0.0.1 → rara_tools-0.0.2}/rara_tools.egg-info/top_level.txt +0 -0
  21. {rara_tools-0.0.1 → rara_tools-0.0.2}/requirements.txt +0 -0
  22. {rara_tools-0.0.1 → rara_tools-0.0.2}/setup.cfg +0 -0
  23. {rara_tools-0.0.1 → rara_tools-0.0.2}/tests/test_s3_exceptions.py +0 -0
  24. {rara_tools-0.0.1 → rara_tools-0.0.2}/tests/test_s3_file_operations.py +0 -0
  25. {rara_tools-0.0.1 → rara_tools-0.0.2}/tests/test_task_reporter.py +0 -0
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: rara-tools
3
+ Version: 0.0.2
4
+ Summary: Tools to support Kata's work.
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Intended Audience :: Science/Research
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE.md
13
+ Requires-Dist: elasticsearch==8.*
14
+ Requires-Dist: elasticsearch_dsl==8.*
15
+ Requires-Dist: minio==7.*
16
+ Requires-Dist: requests
17
+ Provides-Extra: testing
18
+ Requires-Dist: pytest>=8.0; extra == "testing"
19
+ Requires-Dist: pytest-order; extra == "testing"
20
+
21
+ # RaRa Tools
22
+
23
+ ![Py3.10](https://img.shields.io/badge/python-3.10-green.svg)
24
+ ![Py3.11](https://img.shields.io/badge/python-3.11-green.svg)
25
+ ![Py3.12](https://img.shields.io/badge/python-3.12-green.svg)
26
+
27
+ **`rara-tools`** is a Python library containing various generic tools used by components of Kata.
28
+
29
+ ---
30
+
31
+ ## ✨ Features
32
+
33
+ - Elasticsearch index & document operations
34
+ - S3 file management operations
35
+ - Task reporting to Core API
36
+ ---
37
+
38
+ ## ⚡ Quick Start
39
+
40
+ Get started with `rara-tools` in just a few steps:
41
+
42
+ 1. **Install the Package**
43
+ Ensure you're using Python 3.10 or above, then run:
44
+ ```bash
45
+ pip install rara-tools
46
+ ```
47
+
48
+ 2. **Import and Use**
49
+ Example usage to download a folder from S3:
50
+
51
+ ```python
52
+ from rara_tools.s3 import S3Files
53
+
54
+ s3 = S3Files(
55
+ url="your-s3-address",
56
+ access_key = "xxx",
57
+ secret_key = "yyy",
58
+ bucket = "my-sad-bucket"
59
+ )
60
+
61
+ s3.download("my-folder-in-s3")
62
+ ```
63
+
64
+ ---
65
+
66
+ ## ⚙️ Installation Guide
67
+
68
+ Follow the steps below to install the `rara-tools` package, either via `pip` or locally.
69
+
70
+ ---
71
+
72
+ ### Installation via `pip`
73
+
74
+ <details><summary>Click to expand</summary>
75
+
76
+ 1. **Set Up Your Python Environment**
77
+ Create or activate a Python environment using Python **3.10** or above.
78
+
79
+ 2. **Install the Package**
80
+ Run the following command:
81
+ ```bash
82
+ pip install rara-tools
83
+ ```
84
+ </details>
85
+
86
+ ---
87
+
88
+ ### Local Installation
89
+
90
+ Follow these steps to install the `rara-tools` package locally:
91
+
92
+ <details><summary>Click to expand</summary>
93
+
94
+ 1. **Clone the Repository**
95
+ Clone the repository and navigate into it:
96
+ ```bash
97
+ git clone <repository-url>
98
+ cd <repository-directory>
99
+ ```
100
+
101
+ 2. **Set Up Python Environment**
102
+ Create or activate a Python environment using Python 3.10 or above. E.g:
103
+ ```bash
104
+ conda create -n py310 python==3.10
105
+ conda activate py310
106
+ ```
107
+
108
+ 3. **Install Build Package**
109
+ Install the `build` package to enable local builds:
110
+ ```bash
111
+ pip install build
112
+ ```
113
+
114
+ 4. **Build the Package**
115
+ Run the following command inside the repository:
116
+ ```bash
117
+ python -m build
118
+ ```
119
+
120
+ 5. **Install the Package**
121
+ Install the built package locally:
122
+ ```bash
123
+ pip install .
124
+ ```
125
+
126
+ </details>
127
+
128
+ ---
129
+
130
+ ## 🚀 Testing Guide
131
+
132
+ Follow these steps to test the `rara-tools` package.
133
+
134
+
135
+ ### How to Test
136
+
137
+ <details><summary>Click to expand</summary>
138
+
139
+ 1. **Clone the Repository**
140
+ Clone the repository and navigate into it:
141
+ ```bash
142
+ git clone <repository-url>
143
+ cd <repository-directory>
144
+ ```
145
+
146
+ 2. **Set Up Python Environment**
147
+ Create or activate a Python environment using Python 3.10 or above.
148
+
149
+ 3. **Install Build Package**
150
+ Install the `build` package:
151
+ ```bash
152
+ pip install build
153
+ ```
154
+
155
+ 4. **Build the Package**
156
+ Build the package inside the repository:
157
+ ```bash
158
+ python -m build
159
+ ```
160
+
161
+ 5. **Install with Testing Dependencies**
162
+ Install the package along with its testing dependencies:
163
+ ```bash
164
+ pip install .[testing]
165
+ ```
166
+
167
+ 6. **Run Tests**
168
+ Run the test suite from the repository root:
169
+ ```bash
170
+ python -m pytest -v tests
171
+ ```
172
+
173
+ ---
174
+
175
+ </details>
@@ -0,0 +1,155 @@
1
+ # RaRa Tools
2
+
3
+ ![Py3.10](https://img.shields.io/badge/python-3.10-green.svg)
4
+ ![Py3.11](https://img.shields.io/badge/python-3.11-green.svg)
5
+ ![Py3.12](https://img.shields.io/badge/python-3.12-green.svg)
6
+
7
+ **`rara-tools`** is a Python library containing various generic tools used by components of Kata.
8
+
9
+ ---
10
+
11
+ ## ✨ Features
12
+
13
+ - Elasticsearch index & document operations
14
+ - S3 file management operations
15
+ - Task reporting to Core API
16
+ ---
17
+
18
+ ## ⚡ Quick Start
19
+
20
+ Get started with `rara-tools` in just a few steps:
21
+
22
+ 1. **Install the Package**
23
+ Ensure you're using Python 3.10 or above, then run:
24
+ ```bash
25
+ pip install rara-tools
26
+ ```
27
+
28
+ 2. **Import and Use**
29
+ Example usage to download a folder from S3:
30
+
31
+ ```python
32
+ from rara_tools.s3 import S3Files
33
+
34
+ s3 = S3Files(
35
+ url="your-s3-address",
36
+ access_key = "xxx",
37
+ secret_key = "yyy",
38
+ bucket = "my-sad-bucket"
39
+ )
40
+
41
+ s3.download("my-folder-in-s3")
42
+ ```
43
+
44
+ ---
45
+
46
+ ## ⚙️ Installation Guide
47
+
48
+ Follow the steps below to install the `rara-tools` package, either via `pip` or locally.
49
+
50
+ ---
51
+
52
+ ### Installation via `pip`
53
+
54
+ <details><summary>Click to expand</summary>
55
+
56
+ 1. **Set Up Your Python Environment**
57
+ Create or activate a Python environment using Python **3.10** or above.
58
+
59
+ 2. **Install the Package**
60
+ Run the following command:
61
+ ```bash
62
+ pip install rara-tools
63
+ ```
64
+ </details>
65
+
66
+ ---
67
+
68
+ ### Local Installation
69
+
70
+ Follow these steps to install the `rara-tools` package locally:
71
+
72
+ <details><summary>Click to expand</summary>
73
+
74
+ 1. **Clone the Repository**
75
+ Clone the repository and navigate into it:
76
+ ```bash
77
+ git clone <repository-url>
78
+ cd <repository-directory>
79
+ ```
80
+
81
+ 2. **Set Up Python Environment**
82
+ Create or activate a Python environment using Python 3.10 or above. E.g:
83
+ ```bash
84
+ conda create -n py310 python==3.10
85
+ conda activate py310
86
+ ```
87
+
88
+ 3. **Install Build Package**
89
+ Install the `build` package to enable local builds:
90
+ ```bash
91
+ pip install build
92
+ ```
93
+
94
+ 4. **Build the Package**
95
+ Run the following command inside the repository:
96
+ ```bash
97
+ python -m build
98
+ ```
99
+
100
+ 5. **Install the Package**
101
+ Install the built package locally:
102
+ ```bash
103
+ pip install .
104
+ ```
105
+
106
+ </details>
107
+
108
+ ---
109
+
110
+ ## 🚀 Testing Guide
111
+
112
+ Follow these steps to test the `rara-tools` package.
113
+
114
+
115
+ ### How to Test
116
+
117
+ <details><summary>Click to expand</summary>
118
+
119
+ 1. **Clone the Repository**
120
+ Clone the repository and navigate into it:
121
+ ```bash
122
+ git clone <repository-url>
123
+ cd <repository-directory>
124
+ ```
125
+
126
+ 2. **Set Up Python Environment**
127
+ Create or activate a Python environment using Python 3.10 or above.
128
+
129
+ 3. **Install Build Package**
130
+ Install the `build` package:
131
+ ```bash
132
+ pip install build
133
+ ```
134
+
135
+ 4. **Build the Package**
136
+ Build the package inside the repository:
137
+ ```bash
138
+ python -m build
139
+ ```
140
+
141
+ 5. **Install with Testing Dependencies**
142
+ Install the package along with its testing dependencies:
143
+ ```bash
144
+ pip install .[testing]
145
+ ```
146
+
147
+ 6. **Run Tests**
148
+ Run the test suite from the repository root:
149
+ ```bash
150
+ python -m pytest -v tests
151
+ ```
152
+
153
+ ---
154
+
155
+ </details>
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -8,7 +8,7 @@ from .decorators import _elastic_connection
8
8
  class KataElastic:
9
9
  """A class to manage all required Elasticsearch operations for Kata.
10
10
  """
11
- def __init__(self, elasticsearch_url, timeout: Optional[int] = None):
11
+ def __init__(self, elasticsearch_url: str, timeout: Optional[int] = None):
12
12
  self.timeout = timeout
13
13
  self.elasticsearch_url = elasticsearch_url
14
14
  self.elasticsearch = Elasticsearch(self.elasticsearch_url, request_timeout=self.timeout)
@@ -16,7 +16,7 @@ class KataElastic:
16
16
  @_elastic_connection
17
17
  def check(self) -> bool:
18
18
  """Checks Elasticsearch connection.
19
- :return: bool: Elasticsearch accessible or not.
19
+ :return: bool: Elasticsearch alive or dead.
20
20
  """
21
21
  if self.elasticsearch.ping():
22
22
  return True
@@ -31,7 +31,7 @@ class KataElastic:
31
31
  settings: Optional[dict] = None
32
32
  ) -> Dict:
33
33
  """Creates empty index.
34
- :param: index str: Name of the created index.
34
+ :param: index str: Name of the index to create.
35
35
  :param: shards int: Number of shards for the index.
36
36
  :param: replicas int: Number of replicas of the index.
37
37
  :param: settings dict: Overwrite settings for the index.
@@ -43,22 +43,24 @@ class KataElastic:
43
43
  return self.elasticsearch.indices.create(index=index, settings=body)
44
44
 
45
45
  @_elastic_connection
46
- def delete_index(self, index: str, ignore: Optional[bool] = True) -> dict:
46
+ def delete_index(self, index: str, ignore: Optional[bool] = True) -> Dict:
47
47
  """Deletes index.
48
48
  :param: index str: Name of the index to be deleted.
49
49
  :param: ignore bool: Ignore errors because of closed/deleted index.
50
+ :return: Dict of Elastic's acknowledgement of the action.
50
51
  """
51
52
  response = self.elasticsearch.indices.delete(index=index, ignore_unavailable=ignore)
52
53
  return response
53
54
 
54
55
  @_elastic_connection
55
- def delete_document(self, document_id: str, index: str, ignore: Optional[bool] = True) -> dict:
56
+ def delete_document(self, index: str, document_id: str) -> Dict:
56
57
  """Deletes document fom index.
57
58
  :param: document_id str: ID of the document to be deleted.
58
59
  :param: index str: Index where the document is to be found.
59
60
  :param: ignore bool: Ignore errors because of closed/deleted index.
61
+ :return: Dict of Elastic's acknowledgement of the action.
60
62
  """
61
- response = self.elasticsearch.delete(id=document_id, index=index, ignore_unavailable=ignore)
63
+ response = self.elasticsearch.delete(id=document_id, index=index)
62
64
  return response
63
65
 
64
66
  @_elastic_connection
@@ -67,12 +69,13 @@ class KataElastic:
67
69
  :param: index str: Index that document will be indexed into.
68
70
  :param: body dict: Document body.
69
71
  :param: document_id str: Optional id for the document. Is generated automatically if None.
72
+ :return: Dict of Elastic's acknowledgement of the action.
70
73
  """
71
74
  if document_id:
72
- document = self.elasticsearch.index(index=index, id=document_id, body=body)
75
+ indexed = self.elasticsearch.index(index=index, id=document_id, body=body)
73
76
  else:
74
- document = self.elasticsearch.index(index=index, body=body)
75
- return document
77
+ indexed = self.elasticsearch.index(index=index, body=body)
78
+ return indexed
76
79
 
77
80
  @_elastic_connection
78
81
  def get_documents_by_key(self, index: str, document_key: str) -> List:
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  import uuid
3
- from typing import Optional
3
+ from typing import Optional, List, Generator
4
4
  from minio import Minio
5
5
 
6
6
  from .exceptions import S3InitException, S3ConnectionException, S3InputException
@@ -42,7 +42,7 @@ class S3Files:
42
42
  raise S3InputException(f"File '{file_path}' does not exist in file system!")
43
43
  return self.minio_client.fput_object(self.bucket, s3_path_name, file_path)
44
44
 
45
- def list(self, prefix: Optional[str] = ""):
45
+ def list(self, prefix: Optional[str] = "") -> List:
46
46
  """Lists all available files in S3 bucket.
47
47
  :param: prefix str: Limits the listing to a given prefix.
48
48
  :return: List of file paths in S3.
@@ -51,16 +51,18 @@ class S3Files:
51
51
  list_of_objects = [o.object_name for o in list_of_objects]
52
52
  return list_of_objects
53
53
 
54
- def delete(self, path: str):
54
+ def delete(self, path: str) -> bool:
55
55
  """Deletes file in S3.
56
56
  :param: path str: Path of the file in S3 to be deleted.
57
+ :return: True.
57
58
  """
58
59
  list_of_objects = self.minio_client.list_objects(self.bucket, prefix=path, recursive=True)
59
60
  list_of_objects = [o.object_name for o in list_of_objects]
60
61
  for path_to_delete in list_of_objects:
61
62
  self.minio_client.remove_object(self.bucket, path_to_delete)
63
+ return True
62
64
 
63
- def download(self, path: str, download_dir: Optional[str] = "."):
65
+ def download(self, path: str, download_dir: Optional[str] = ".") -> Generator[str, str, str]:
64
66
  """Downloads file or folder from S3.
65
67
  :param: path str: Path to the file or folder in S3.
66
68
  :param: download_dir str: Directory to download the files and folders into.
@@ -72,26 +74,26 @@ class S3Files:
72
74
  self.minio_client.fget_object(self.bucket, minio_object.object_name, full_path)
73
75
  yield full_path
74
76
 
75
- def upload(self, path: str, prefix: Optional[str] = ""):
77
+ def upload(self, path: str, prefix: Optional[str] = "") -> str:
76
78
  """Uploads file or folder to S3 bucket.
77
79
  :param: path str: Path to the file to upload in local file system.
78
80
  :param: prefix str: Optional prefix for S3 path.
79
81
  :returns: File path of the uploaded file or folder in S3.
80
82
  """
81
- path_name = os.path.split(path)[-1]
82
83
  # Manage directories
83
84
  if os.path.isdir(path):
84
85
  s3_path_prefix = f"{prefix}{uuid.uuid4().hex}"
85
86
  for root, _, files in os.walk(path):
86
87
  for file in files:
88
+ relative_prefix = root.removeprefix(path).lstrip("/")
87
89
  file_path = os.path.join(root, file)
88
90
  extension = file.split(".")[-1]
89
- s3_file_name = f"{uuid.uuid4().hex}.{extension}"
90
- s3_path_name = os.path.join(s3_path_prefix, s3_file_name)
91
+ s3_path_name = os.path.join(s3_path_prefix, relative_prefix, file)
91
92
  self._put_file(file_path, s3_path_name)
92
93
  return s3_path_prefix
93
94
  # Manage single files
94
95
  else:
96
+ path_name = os.path.split(path)[-1]
95
97
  extension = path_name.split(".")[-1]
96
98
  s3_path_name = f"{prefix}{uuid.uuid4().hex}.{extension}"
97
99
  self._put_file(path, s3_path_name)
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: rara-tools
3
+ Version: 0.0.2
4
+ Summary: Tools to support Kata's work.
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.10
7
+ Classifier: Programming Language :: Python :: 3.11
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Intended Audience :: Science/Research
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE.md
13
+ Requires-Dist: elasticsearch==8.*
14
+ Requires-Dist: elasticsearch_dsl==8.*
15
+ Requires-Dist: minio==7.*
16
+ Requires-Dist: requests
17
+ Provides-Extra: testing
18
+ Requires-Dist: pytest>=8.0; extra == "testing"
19
+ Requires-Dist: pytest-order; extra == "testing"
20
+
21
+ # RaRa Tools
22
+
23
+ ![Py3.10](https://img.shields.io/badge/python-3.10-green.svg)
24
+ ![Py3.11](https://img.shields.io/badge/python-3.11-green.svg)
25
+ ![Py3.12](https://img.shields.io/badge/python-3.12-green.svg)
26
+
27
+ **`rara-tools`** is a Python library containing various generic tools used by components of Kata.
28
+
29
+ ---
30
+
31
+ ## ✨ Features
32
+
33
+ - Elasticsearch index & document operations
34
+ - S3 file management operations
35
+ - Task reporting to Core API
36
+ ---
37
+
38
+ ## ⚡ Quick Start
39
+
40
+ Get started with `rara-tools` in just a few steps:
41
+
42
+ 1. **Install the Package**
43
+ Ensure you're using Python 3.10 or above, then run:
44
+ ```bash
45
+ pip install rara-tools
46
+ ```
47
+
48
+ 2. **Import and Use**
49
+ Example usage to download a folder from S3:
50
+
51
+ ```python
52
+ from rara_tools.s3 import S3Files
53
+
54
+ s3 = S3Files(
55
+ url="your-s3-address",
56
+ access_key = "xxx",
57
+ secret_key = "yyy",
58
+ bucket = "my-sad-bucket"
59
+ )
60
+
61
+ s3.download("my-folder-in-s3")
62
+ ```
63
+
64
+ ---
65
+
66
+ ## ⚙️ Installation Guide
67
+
68
+ Follow the steps below to install the `rara-tools` package, either via `pip` or locally.
69
+
70
+ ---
71
+
72
+ ### Installation via `pip`
73
+
74
+ <details><summary>Click to expand</summary>
75
+
76
+ 1. **Set Up Your Python Environment**
77
+ Create or activate a Python environment using Python **3.10** or above.
78
+
79
+ 2. **Install the Package**
80
+ Run the following command:
81
+ ```bash
82
+ pip install rara-tools
83
+ ```
84
+ </details>
85
+
86
+ ---
87
+
88
+ ### Local Installation
89
+
90
+ Follow these steps to install the `rara-tools` package locally:
91
+
92
+ <details><summary>Click to expand</summary>
93
+
94
+ 1. **Clone the Repository**
95
+ Clone the repository and navigate into it:
96
+ ```bash
97
+ git clone <repository-url>
98
+ cd <repository-directory>
99
+ ```
100
+
101
+ 2. **Set Up Python Environment**
102
+ Create or activate a Python environment using Python 3.10 or above. E.g:
103
+ ```bash
104
+ conda create -n py310 python==3.10
105
+ conda activate py310
106
+ ```
107
+
108
+ 3. **Install Build Package**
109
+ Install the `build` package to enable local builds:
110
+ ```bash
111
+ pip install build
112
+ ```
113
+
114
+ 4. **Build the Package**
115
+ Run the following command inside the repository:
116
+ ```bash
117
+ python -m build
118
+ ```
119
+
120
+ 5. **Install the Package**
121
+ Install the built package locally:
122
+ ```bash
123
+ pip install .
124
+ ```
125
+
126
+ </details>
127
+
128
+ ---
129
+
130
+ ## 🚀 Testing Guide
131
+
132
+ Follow these steps to test the `rara-tools` package.
133
+
134
+
135
+ ### How to Test
136
+
137
+ <details><summary>Click to expand</summary>
138
+
139
+ 1. **Clone the Repository**
140
+ Clone the repository and navigate into it:
141
+ ```bash
142
+ git clone <repository-url>
143
+ cd <repository-directory>
144
+ ```
145
+
146
+ 2. **Set Up Python Environment**
147
+ Create or activate a Python environment using Python 3.10 or above.
148
+
149
+ 3. **Install Build Package**
150
+ Install the `build` package:
151
+ ```bash
152
+ pip install build
153
+ ```
154
+
155
+ 4. **Build the Package**
156
+ Build the package inside the repository:
157
+ ```bash
158
+ python -m build
159
+ ```
160
+
161
+ 5. **Install with Testing Dependencies**
162
+ Install the package along with its testing dependencies:
163
+ ```bash
164
+ pip install .[testing]
165
+ ```
166
+
167
+ 6. **Run Tests**
168
+ Run the test suite from the repository root:
169
+ ```bash
170
+ python -m pytest -v tests
171
+ ```
172
+
173
+ ---
174
+
175
+ </details>
@@ -12,6 +12,7 @@ es_url = os.getenv("ELASTIC_TEST_URL", "http://localhost:9200")
12
12
  ELASTIC = KataElastic(es_url)
13
13
  ELASTIC_BAD = KataElastic("http://locallost:9012")
14
14
  TEST_INDEX_NAME = "tools_testing_index"
15
+ TEST_DOCUMENT_ID = None
15
16
 
16
17
 
17
18
  @pytest.mark.order(1)
@@ -43,11 +44,24 @@ def test_get_document_by_key():
43
44
  result = ELASTIC.get_documents_by_key(TEST_INDEX_NAME, "foo")
44
45
  assert len(result) == 2
45
46
  result = ELASTIC.get_documents_by_key(TEST_INDEX_NAME, "bar")
47
+ global TEST_DOCUMENT_ID
48
+ TEST_DOCUMENT_ID = result[0].meta.id
46
49
  assert len(result) == 1
47
50
  result = ELASTIC.get_documents_by_key(TEST_INDEX_NAME, "loll")
48
51
  assert len(result) == 0
49
52
 
50
- @pytest.mark.order(4)
53
+ @pytest.mark.order(5)
54
+ def test_document_deleting():
55
+ """ Tests deleting a document from index.
56
+ """
57
+ deleted = ELASTIC.delete_document(TEST_INDEX_NAME, TEST_DOCUMENT_ID)
58
+ assert deleted["result"] == "deleted"
59
+ sleep(1)
60
+ # check if document was actually deleted
61
+ result = ELASTIC.get_documents_by_key(TEST_INDEX_NAME, "bar")
62
+ assert len(result) == 0
63
+
64
+ @pytest.mark.order(5)
51
65
  def test_index_deleting():
52
66
  """ Tests deleting index. We delete the test index now.
53
67
  """
rara_tools-0.0.1/PKG-INFO DELETED
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: rara-tools
3
- Version: 0.0.1
4
- Summary: Tools to support Kata's work.
5
- Classifier: Programming Language :: Python :: 3
6
- Classifier: Programming Language :: Python :: 3.10
7
- Classifier: Programming Language :: Python :: 3.11
8
- Classifier: Programming Language :: Python :: 3.12
9
- Classifier: Intended Audience :: Science/Research
10
- Requires-Python: >=3.10
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE.md
13
- Requires-Dist: elasticsearch==8.*
14
- Requires-Dist: elasticsearch_dsl==8.*
15
- Requires-Dist: minio==7.*
16
- Requires-Dist: requests
17
- Provides-Extra: testing
18
- Requires-Dist: pytest>=8.0; extra == "testing"
19
- Requires-Dist: pytest-order; extra == "testing"
20
-
21
- # rara-tools
@@ -1 +0,0 @@
1
- # rara-tools
rara_tools-0.0.1/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.1
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: rara-tools
3
- Version: 0.0.1
4
- Summary: Tools to support Kata's work.
5
- Classifier: Programming Language :: Python :: 3
6
- Classifier: Programming Language :: Python :: 3.10
7
- Classifier: Programming Language :: Python :: 3.11
8
- Classifier: Programming Language :: Python :: 3.12
9
- Classifier: Intended Audience :: Science/Research
10
- Requires-Python: >=3.10
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE.md
13
- Requires-Dist: elasticsearch==8.*
14
- Requires-Dist: elasticsearch_dsl==8.*
15
- Requires-Dist: minio==7.*
16
- Requires-Dist: requests
17
- Provides-Extra: testing
18
- Requires-Dist: pytest>=8.0; extra == "testing"
19
- Requires-Dist: pytest-order; extra == "testing"
20
-
21
- # rara-tools
File without changes
File without changes
File without changes
File without changes