Skip to content

Commit ab0da24

Browse files
authored
New SDK changes (#13)
* Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge * Initial merge
1 parent bbf9e89 commit ab0da24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1006
-1648
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pip install --upgrade unicourt
2121
Install from source :
2222

2323
```sh
24+
export SDK_VERSION=<new sdk version>
2425
python setup.py install
2526
```
2627

@@ -80,4 +81,4 @@ for attorney in attorney_obj.norm_attorney_search_result_array:
8081
Authentication.invalidate_token()
8182

8283

83-
```
84+
```

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@
44
os.chdir(here)
55

66
NAME = "unicourt"
7-
VERSION = "1.0"
7+
VERSION = os.getenv("SDK_VERSION")
88
# To install the library, run the following
99
#
1010
# python setup.py install
1111
#
1212
# prerequisite: setuptools
1313
# http://pypi.python.org/pypi/setuptools
1414

15-
REQUIRES = [
16-
"urllib3 >= 1.25.3",
17-
"python-dateutil",
18-
]
19-
15+
REQUIRES = ["python_dateutil >= 2.5.3", "urllib3 >= 1.25.3"]
2016

2117
setup(
2218
name=NAME,
2319
version=VERSION,
2420
description="Python bindings for the UniCourt Enterprise APIs",
2521
author="UniCourt",
2622
author_email="[email protected]",
23+
license="",
2724
url="https://unicourt.com/",
25+
project_urls={
26+
"Source": "https://github.com/UniCourt/enterprise-api-py-sdk/tree/main",
27+
"Documentation": "https://docs.unicourt.com/",
28+
},
2829
keywords=["UniCourt", "UniCourt Python Package",
2930
"UniCourt Enterprise APIs"],
3031
python_requires=">=3.6",

test/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ ENV CLIENT_ID $CLIENT_ID
77
ARG CLIENT_SECRET
88
ENV CLIENT_SECRET $CLIENT_SECRET
99

10-
1110
ARG PACER_CLIENT_CODE
1211
ENV PACER_CLIENT_CODE $PACER_CLIENT_CODE
1312

14-
1513
ARG PACER_USER_ID
1614
ENV PACER_USER_ID $PACER_USER_ID
1715

16+
ARG SDK_VERSION
17+
ENV SDK_VERSION $SDK_VERSION
18+
1819
WORKDIR /app
1920
RUN git clone https://github.com/UniCourt/enterprise-api-py-sdk.git
2021
RUN python enterprise-api-py-sdk/setup.py install
21-
RUN python enterprise-api-py-sdk/test/base.py --exclude TestPacer
22-
23-
# docker build -t test_sdh --build-arg CLIENT_ID=G3cfixgetVzfaoszGOBp5LPGtih1nMJ9 --build-arg CLIENT_SECRET=u6PTti57IjPlrwU5MzOwLBD2MCwx-IEbo8sTStTivh1I-EqQ8Jcm27Gfo2GhpHCw --build-arg PACER_CLIENT_CODE=xyz_client --build-arg PACER_USER_ID=pcrid .
22+
RUN python enterprise-api-py-sdk/test/base.py --exclude TestPacer

test/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ To run the SDK tests you need python >= 3.6 and Git installed.
2525
2626
EXPORT CLIENT_SECRET=”u6PTti57IjPlrwU5MzOwLBD2MCwx-IEbo8sTStTivh1I-EqQ8Jcm27Gf”
2727
28-
EXPORT PACER_CLIENT_CODE=”xyz_client”
29-
PACER_USER_ID CLIENT_ID=”pcrid”
28+
EXPORT PACER_CLIENT_CODE=”xyz_client_code”
29+
30+
EXPORT PACER_USER_ID=”pcrid”
31+
32+
EXPORT CLIENT_ID=”client_id”
3033
3134
python3 enterprise-api-py-sdk/test/base.py --exclude TestPacer
3235
```
3336

3437
**Method 2 :** Use the Dockerfile in the test directory. Open up the terminal and run the below given command
3538

3639
```
37-
docker build -t test_unicourt_sdk --build-arg CLIENT_ID=G3cfixgetVzfaoszGOBp5LPGtih1nMJ9 --build-arg CLIENT_SECRET=u6PTti57IjPlrwU5MzOwLBD2MCwx-IEbo8sTStTivh1I-EqQ8Jcm27Gfo2GhpHCw --build-arg PACER_CLIENT_CODE=xyz_client --build-arg PACER_USER_ID=pcrid .
40+
docker build -t test_unicourt_sdk --build-arg SDK_VERSION=1.0 --build-arg CLIENT_ID=G3cfixgetVzfaoszGOBp5LPGtih1nMJ9 --build-arg CLIENT_SECRET=u6PTti57IjPlrwU5MzOwLBD2MCwx-IEbo8sTStTivh1I-EqQ8Jcm27Gfo2GhpHCw --build-arg PACER_CLIENT_CODE=xyz_client_code --build-arg PACER_USER_ID=pcrid .
3841
```
3942

4043
Above command will execute the tests and the results are printed out on the terminal.

test/__init__.py

Whitespace-only changes.

test/base.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import argparse
2+
import importlib
23
import os
34
import re
45
import time
56
import unicourt
67
from unicourt.sdk.Authentication import Authentication
78

8-
99
class TestBase:
1010
def __init__(self) -> None:
1111
self.parser = argparse.ArgumentParser()
@@ -19,36 +19,33 @@ def __init__(self) -> None:
1919

2020
def run(self):
2121
args = self.parser.parse_args()
22-
for module_name in [re.sub("\.py", "", module)
23-
for module in os.listdir(os.path.dirname(os.path.abspath(__file__))) if module.startswith("test") and module.endswith("py")]:
22+
# getting the list of test file and re-order authentication test file at end to run.
23+
module_list = [re.sub("\.py", "", module) for module in os.listdir() if module.startswith("test") and module.endswith("py")]
24+
index = module_list.index('test_authentication_api')
25+
module_list[index], module_list[-1] = module_list[-1], module_list[index]
26+
for module_name in module_list:
2427
module = __import__(module_name)
25-
class_name = [class_name for class_name in dir(
26-
module) if class_name.startswith('Test')][0]
27-
if class_name == 'TestAuthentication':
28-
continue
28+
class_name = [class_name for class_name in dir(module) if class_name.startswith('Test')][0]
2929
if args.exclude:
3030
if class_name in args.exclude.split(","):
3131
continue
3232
if args.include:
3333
if class_name not in args.include.split(","):
3434
continue
35+
print("########### Testing", class_name, "###########\n")
3536
instance_obj = getattr(module, class_name)
36-
37-
method_list = [meth for meth in dir(
38-
instance_obj) if meth.startswith('test') is True]
37+
method_list = [meth for meth in dir(instance_obj) if meth.startswith('test') is True]
3938
for method_name in method_list:
4039
if hasattr(instance_obj, method_name) and callable(function := getattr(instance_obj, method_name)):
4140
try:
4241
_, status_code = function()
43-
print(method_name, status_code)
44-
time.sleep(1)
42+
print("Method:", method_name, "\nStatus Code:", status_code, "\n")
43+
time.sleep(5)
4544
except Exception as e:
46-
Authentication.invalidate_token()
47-
raise Exception(e)
48-
45+
print("Method:", method_name, "\nError", e)
4946

5047
def main():
51-
print("############ Starting Test for SDK ############")
48+
print("########### Starting Test for SDK ###########\n")
5249
TestBase().run()
5350

5451

test/test_authentication_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def test_invalidate_token():
1616
response = Authentication.generate_new_token()
1717
return Authentication.invalidate_token(token_id=response[0].token_id)
1818

19-
# def test_invalidate_all_tokens():
20-
# return Authentication.invalidate_all_tokens()
19+
def test_invalidate_all_tokens():
20+
return Authentication.invalidate_all_tokens()

test/test_case_document_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
class TestCaseDocuments:
77

8-
# def test_get_case_document_download_by_id_with_no_preview():
9-
# return CaseDocuments.get_case_document_download_by_id(
10-
# case_document_id='CDOCaqe42a86394f63',
11-
# is_preview_document=True
12-
# )
8+
def test_get_case_document_download_by_id_with_no_preview():
9+
return CaseDocuments.get_case_document_download_by_id(
10+
case_document_id='CDOCaqe42a86394f63',
11+
is_preview_document=True
12+
)
1313

1414
def test_get_case_document_download_by_id_with_preview():
1515
return CaseDocuments.get_case_document_download_by_id(

test/test_pacer_credential_api.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from unicourt.model.pacer_credential_request import PacerCredentialRequest
22
from unicourt.sdk.PACERCredential import PACERCredential
3-
import os
43

54

65
class TestPacerCredentials:
76
def test_add_pacer_credential():
87
pacer_credential_request = PacerCredentialRequest(
9-
pacer_user_id="TEST_PACER_USER_ID",
10-
default_pacer_client_code="TEST_CLIENT_CODE",
11-
password="TEST_PASSWORD"
8+
pacer_user_id=os.getenv("PACER_USER_ID"),
9+
default_pacer_client_code=os.getenv("PACER_CLIENT_CODE"),
10+
password="TEST_PASSWORD",
1211
)
1312
return PACERCredential.add_pacer_credential(
1413
pacer_credential_request=pacer_credential_request)
@@ -19,10 +18,10 @@ def test_get_pacer_credential():
1918

2019
def test_get_pacer_credential_by_id():
2120
return PACERCredential.get_pacer_credential_by_id(
22-
pacer_user_id="TEST_PACER_USER_ID"
21+
pacer_user_id=os.getenv("PACER_USER_ID"),
2322
)
2423

2524
def test_remove_pacer_credential_by_id():
2625
return PACERCredential.remove_pacer_credential_by_id(
27-
pacer_user_id="TEST_PACER_USER_ID"
26+
pacer_user_id=os.getenv("PACER_USER_ID")
2827
)

test/test_party_analytics_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33

44
class TestPartyAnalytics:
5-
# Test all Analytics APIs
6-
75
def test_get_norm_attorneys_associated_with_norm_party():
86
return PartyAnalytics.get_norm_attorneys_associated_with_norm_party(
97
q='caseTypeId:"CTYPATMYyaJekdgj2c" AND caseFiledDate:[2017-01-01T00:00:00+00:00TO2021-11-30T00:00:00+00:00]',

0 commit comments

Comments
 (0)