Skip to content

Commit

Permalink
New SDK changes (#17)
Browse files Browse the repository at this point in the history
* Update test_usage_api.py (#9)

* Updated test_get_billing_usage_by_billing_cycle to fetch billing cycle date from test_get_billing_cycles (#10)

* Removed log function from test base

* Updated test_get_billing_usage_by_billing_cycle to fetch billing cycle from test_get_billing_cycles

* Merging changes to testing test workflows (#12)

* Update test_usage_api.py

* Sync dev with main (#11)

* Update test_usage_api.py (#9)

* Updated test_get_billing_usage_by_billing_cycle to fetch billing cycle date from test_get_billing_cycles (#10)

* Removed log function from test base

* Updated test_get_billing_usage_by_billing_cycle to fetch billing cycle from test_get_billing_cycles

---------

Co-authored-by: santhosh-uc <[email protected]>

* Update test_party_analytics_api.py

---------

Co-authored-by: santhosh-uc <[email protected]>

* 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

* Initial merge (#14)

* Change to run test

* Change to run test (#15)

* Adding statement to echo secrets

* Update run_sdk_test.yml

* Update run_sdk_test.yml

* Updated test workflow

* Adding statement to echo secrets in GitHub action workflow (#16)

* Change to run test

* Adding statement to echo secrets

* Update run_sdk_test.yml

* Update run_sdk_test.yml

* Updated test workflow

* Initial merge

---------

Co-authored-by: pshenoy-uc <[email protected]>
Co-authored-by: santhosh-uc <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent 4755575 commit f05014a
Show file tree
Hide file tree
Showing 50 changed files with 1,019 additions and 1,656 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/run_sdk_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
branches:
- main
jobs:
run-script:
test:
runs-on: ubuntu-latest
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -16,10 +19,9 @@ jobs:
python-version: '3.9'
- name: Install UniCourt Python SDK
run: python setup.py install
- name: Checking secrets exist
run: echo "CLIENT_ID is ${{secrets.CLIENT_ID}} and CLIENT_SECRET is ${{secrets.CLIENT_SECRET}}"
- name: Checking env's exist
run: echo "CLIENT_ID is $CLIENT_ID and CLIENT_SECRET is $CLIENT_SECRET"
- name: Run SDK test
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PACER_USER_ID: ${{ secrets.PACER_USER_ID }}
PACER_CLIENT_CODE: ${{ secrets.PACER_CLIENT_CODE }}
run: python test/base.py --exclude TestPacer
run: cd test && python base.py --exclude TestPacer
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pip install --upgrade unicourt
Install from source :

```sh
export SDK_VERSION=<new sdk version>
python setup.py install
```

Expand Down Expand Up @@ -80,4 +81,4 @@ for attorney in attorney_obj.norm_attorney_search_result_array:
Authentication.invalidate_token()


```
```
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@
os.chdir(here)

NAME = "unicourt"
VERSION = "1.0"
VERSION = os.getenv("SDK_VERSION")
# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

REQUIRES = [
"urllib3 >= 1.25.3",
"python-dateutil",
]

REQUIRES = ["python_dateutil >= 2.5.3", "urllib3 >= 1.25.3"]

setup(
name=NAME,
version=VERSION,
description="Python bindings for the UniCourt Enterprise APIs",
author="UniCourt",
author_email="[email protected]",
license="",
url="https://unicourt.com/",
project_urls={
"Source": "https://github.com/UniCourt/enterprise-api-py-sdk/tree/main",
"Documentation": "https://docs.unicourt.com/",
},
keywords=["UniCourt", "UniCourt Python Package",
"UniCourt Enterprise APIs"],
python_requires=">=3.6",
Expand Down
9 changes: 4 additions & 5 deletions test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ ENV CLIENT_ID $CLIENT_ID
ARG CLIENT_SECRET
ENV CLIENT_SECRET $CLIENT_SECRET


ARG PACER_CLIENT_CODE
ENV PACER_CLIENT_CODE $PACER_CLIENT_CODE


ARG PACER_USER_ID
ENV PACER_USER_ID $PACER_USER_ID

ARG SDK_VERSION
ENV SDK_VERSION $SDK_VERSION

WORKDIR /app
RUN git clone https://github.com/UniCourt/enterprise-api-py-sdk.git
RUN python enterprise-api-py-sdk/setup.py install
RUN python enterprise-api-py-sdk/test/base.py --exclude TestPacer

# 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 .
RUN cd enterprise-api-py-sdk/test/ && python base.py --exclude TestPacer
9 changes: 6 additions & 3 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ To run the SDK tests you need python >= 3.6 and Git installed.
EXPORT CLIENT_SECRET=”u6PTti57IjPlrwU5MzOwLBD2MCwx-IEbo8sTStTivh1I-EqQ8Jcm27Gf”
EXPORT PACER_CLIENT_CODE=”xyz_client”
PACER_USER_ID CLIENT_ID=”pcrid”
EXPORT PACER_CLIENT_CODE=”xyz_client_code”
EXPORT PACER_USER_ID=”pcrid”
EXPORT CLIENT_ID=”client_id”
python3 enterprise-api-py-sdk/test/base.py --exclude TestPacer
```

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

```
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 .
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 .
```

Above command will execute the tests and the results are printed out on the terminal.
Expand Down
Empty file removed test/__init__.py
Empty file.
29 changes: 13 additions & 16 deletions test/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import argparse
import importlib
import os
import re
import time
import unicourt
from unicourt.sdk.Authentication import Authentication


class TestBase:
def __init__(self) -> None:
self.parser = argparse.ArgumentParser()
Expand All @@ -19,36 +19,33 @@ def __init__(self) -> None:

def run(self):
args = self.parser.parse_args()
for module_name in [re.sub("\.py", "", module)
for module in os.listdir(os.path.dirname(os.path.abspath(__file__))) if module.startswith("test") and module.endswith("py")]:
# getting the list of test file and re-order authentication test file at end to run.
module_list = [re.sub("\.py", "", module) for module in os.listdir() if module.startswith("test") and module.endswith("py")]
index = module_list.index('test_authentication_api')
module_list[index], module_list[-1] = module_list[-1], module_list[index]
for module_name in module_list:
module = __import__(module_name)
class_name = [class_name for class_name in dir(
module) if class_name.startswith('Test')][0]
if class_name == 'TestAuthentication':
continue
class_name = [class_name for class_name in dir(module) if class_name.startswith('Test')][0]
if args.exclude:
if class_name in args.exclude.split(","):
continue
if args.include:
if class_name not in args.include.split(","):
continue
print("########### Testing", class_name, "###########\n")
instance_obj = getattr(module, class_name)

method_list = [meth for meth in dir(
instance_obj) if meth.startswith('test') is True]
method_list = [meth for meth in dir(instance_obj) if meth.startswith('test') is True]
for method_name in method_list:
if hasattr(instance_obj, method_name) and callable(function := getattr(instance_obj, method_name)):
try:
_, status_code = function()
print(method_name, status_code)
time.sleep(1)
print("Method:", method_name, "\nStatus Code:", status_code, "\n")
time.sleep(5)
except Exception as e:
Authentication.invalidate_token()
raise Exception(e)

print("Method:", method_name, "\nError", e)

def main():
print("############ Starting Test for SDK ############")
print("########### Starting Test for SDK ###########\n")
TestBase().run()


Expand Down
4 changes: 2 additions & 2 deletions test/test_authentication_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def test_invalidate_token():
response = Authentication.generate_new_token()
return Authentication.invalidate_token(token_id=response[0].token_id)

# def test_invalidate_all_tokens():
# return Authentication.invalidate_all_tokens()
def test_invalidate_all_tokens():
return Authentication.invalidate_all_tokens()
10 changes: 5 additions & 5 deletions test/test_case_document_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

class TestCaseDocuments:

# def test_get_case_document_download_by_id_with_no_preview():
# return CaseDocuments.get_case_document_download_by_id(
# case_document_id='CDOCaqe42a86394f63',
# is_preview_document=True
# )
def test_get_case_document_download_by_id_with_no_preview():
return CaseDocuments.get_case_document_download_by_id(
case_document_id='CDOCaqe42a86394f63',
is_preview_document=True
)

def test_get_case_document_download_by_id_with_preview():
return CaseDocuments.get_case_document_download_by_id(
Expand Down
12 changes: 6 additions & 6 deletions test/test_pacer_credential_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
from unicourt.model.pacer_credential_request import PacerCredentialRequest
from unicourt.sdk.PACERCredential import PACERCredential
import os


class TestPacerCredentials:
def test_add_pacer_credential():
pacer_credential_request = PacerCredentialRequest(
pacer_user_id="TEST_PACER_USER_ID",
default_pacer_client_code="TEST_CLIENT_CODE",
password="TEST_PASSWORD"
pacer_user_id=os.getenv("PACER_USER_ID"),
default_pacer_client_code=os.getenv("PACER_CLIENT_CODE"),
password="TEST_PASSWORD",
)
return PACERCredential.add_pacer_credential(
pacer_credential_request=pacer_credential_request)
Expand All @@ -19,10 +19,10 @@ def test_get_pacer_credential():

def test_get_pacer_credential_by_id():
return PACERCredential.get_pacer_credential_by_id(
pacer_user_id="TEST_PACER_USER_ID"
pacer_user_id=os.getenv("PACER_USER_ID"),
)

def test_remove_pacer_credential_by_id():
return PACERCredential.remove_pacer_credential_by_id(
pacer_user_id="TEST_PACER_USER_ID"
pacer_user_id=os.getenv("PACER_USER_ID")
)
2 changes: 0 additions & 2 deletions test/test_party_analytics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@


class TestPartyAnalytics:
# Test all Analytics APIs

def test_get_norm_attorneys_associated_with_norm_party():
return PartyAnalytics.get_norm_attorneys_associated_with_norm_party(
q='caseTypeId:"CTYPATMYyaJekdgj2c" AND caseFiledDate:[2017-01-01T00:00:00+00:00TO2021-11-30T00:00:00+00:00]',
Expand Down
1 change: 0 additions & 1 deletion test/test_usage_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ def test_get_billing_usage_by_billing_cycle():
billing_cycle=billing_cycle_date)

def test_get_daily_usage_by_date():
# Get daily usage
return Usage.get_daily_usage_by_date(date='2023-02-21')
14 changes: 7 additions & 7 deletions unicourt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
from unicourt.exceptions import ApiException

from unicourt.sdk.CaseUpdate import CaseUpdate
from unicourt.sdk.AttorneyAnalytics import AttorneyAnalytics
from unicourt.sdk.PACERCredential import PACERCredential
from unicourt.sdk.Usage import Usage
from unicourt.sdk.LawFirmAnalytics import LawFirmAnalytics
from unicourt.sdk.CaseDocuments import CaseDocuments
from unicourt.sdk.CaseDocket import CaseDocket
from unicourt.sdk.CaseSearch import CaseSearch
from unicourt.sdk.CourtStandards import CourtStandards
from unicourt.sdk.CaseSearch import CaseSearch
from unicourt.sdk.Callback import Callback
from unicourt.sdk.AttorneyAnalytics import AttorneyAnalytics
from unicourt.sdk.PartyAnalytics import PartyAnalytics
from unicourt.sdk.Usage import Usage
from unicourt.sdk.CaseExport import CaseExport
from unicourt.sdk.Authentication import Authentication
from unicourt.sdk.CourtAvailability import CourtAvailability
from unicourt.sdk.JudgeAnalytics import JudgeAnalytics
from unicourt.sdk.CaseTracking import CaseTracking
from unicourt.sdk.Callback import Callback
from unicourt.sdk.PACER import PACER
from unicourt.sdk.CaseDocket import CaseDocket
from unicourt.sdk.CaseAnalytics import CaseAnalytics
from unicourt.sdk.PACERCredential import PACERCredential
from unicourt.sdk.CourtAvailability import CourtAvailability


ACCESS_TOKEN = ""
Expand Down
Loading

0 comments on commit f05014a

Please sign in to comment.