Skip to content

Commit 3666fe2

Browse files
committed
Raise UnimplementedError when cert option is used
Problem: The cert keyword argument to Archivist() was never implemented. Solution: Specifying cert will raise ArchivistNotImplemented error. Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
1 parent b2bcdf1 commit 3666fe2

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

archivist/archivist.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
import logging
3434

3535
import json
36-
from os.path import isfile as os_path_isfile
36+
37+
# from os.path import isfile as os_path_isfile
3738
from typing import BinaryIO, Dict, List, Optional
3839
from collections import deque
3940
from copy import deepcopy
@@ -55,6 +56,7 @@
5556
ArchivistDuplicateError,
5657
ArchivistIllegalArgumentError,
5758
ArchivistNotFoundError,
59+
ArchivistNotImplementedError,
5860
)
5961
from .headers import _headers_get
6062
from .retry429 import retry_429
@@ -89,7 +91,7 @@ class Archivist: # pylint: disable=too-many-instance-attributes
8991
Args:
9092
url (str): URL of archivist endpoint
9193
auth: string representing JWT token.
92-
cert: filepath containing both private key and certificate
94+
cert: filepath containing both private key and certificate (not implemented)
9395
verify: if True the certificate is verified
9496
max_time (int): maximum time in seconds to wait for confirmation
9597
@@ -128,8 +130,9 @@ def __init__(
128130
)
129131

130132
if cert:
131-
if not os_path_isfile(cert):
132-
raise ArchivistNotFoundError(f"Cert file {cert} does not exist")
133+
raise ArchivistNotImplementedError("Cert option is not implemented")
134+
# if not os_path_isfile(cert):
135+
# raise ArchivistNotFoundError(f"Cert file {cert} does not exist")
133136

134137
self._cert = cert
135138
self._response_ring_buffer = deque(maxlen=self.RING_BUFFER_MAX_LEN)

archivist/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Archivist4xxError(ArchivistError):
6363

6464

6565
class ArchivistNotImplementedError(ArchivistError):
66-
"""Illegal REST verb (501)"""
66+
"""Illegal REST verb (501) or option"""
6767

6868

6969
class ArchivistUnavailableError(ArchivistError):

unittests/testarchivist.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
ArchivistDuplicateError,
1414
ArchivistIllegalArgumentError,
1515
ArchivistNotFoundError,
16+
ArchivistNotImplementedError,
1617
ArchivistTooManyRequestsError,
1718
)
1819

@@ -129,27 +130,32 @@ def test_archivist_with_both_auth_and_cert(self):
129130
with self.assertRaises(ArchivistIllegalArgumentError):
130131
arch = Archivist("url", auth="authauthauth", cert="/path/to/file")
131132

132-
@mock.patch("archivist.archivist.os_path_isfile")
133-
def test_archivist_with_nonexistent_cert(self, mock_isfile):
133+
# @mock.patch("archivist.archivist.os_path_isfile")
134+
# def test_archivist_with_nonexistent_cert(self, mock_isfile):
135+
def test_archivist_with_nonexistent_cert(self):
134136
"""
135137
Test archivist creation with nonexistent cert
136138
"""
137-
mock_isfile.return_value = False
138-
with self.assertRaises(ArchivistNotFoundError):
139+
# mock_isfile.return_value = False
140+
# with self.assertRaises(ArchivistNotFoundError):
141+
with self.assertRaises(ArchivistNotImplementedError):
139142
arch = Archivist("url", cert="/path/to/file")
140143

141-
@mock.patch("archivist.archivist.os_path_isfile")
142-
def test_archivist_with_existent_cert(self, mock_isfile):
144+
# @mock.patch("archivist.archivist.os_path_isfile")
145+
# def test_archivist_with_existent_cert(self, mock_isfile):
146+
def test_archivist_with_existent_cert(self):
143147
"""
144-
Test archivist creation with cert
148+
Test archivist creation with cert - not currently implemented
145149
"""
146-
mock_isfile.return_value = True
147-
arch = Archivist("url", cert="/path/to/file")
148-
self.assertEqual(
149-
arch.cert,
150-
"/path/to/file",
151-
msg="verify must be False",
152-
)
150+
with self.assertRaises(ArchivistNotImplementedError):
151+
arch = Archivist("url", cert="/path/to/file")
152+
# mock_isfile.return_value = True
153+
# arch = Archivist("url", cert="/path/to/file")
154+
# self.assertEqual(
155+
# arch.cert,
156+
# "/path/to/file",
157+
# msg="verify must be False",
158+
# )
153159

154160

155161
class TestArchivistMethods(TestCase):

0 commit comments

Comments
 (0)