Skip to content

Commit

Permalink
Test cases added
Browse files Browse the repository at this point in the history
* failing test cases errors resolved

* Pytest version updated

* Comments Resolved

* Workflow changes

* Workflow changes

* coveragerc file added

* New testcases added

* New testcases added

* Renamed all test data files to data.json || Vendor payments test resolved

* Coverage 90%

* APPId added to yml file | Comments resolved | gitignore updated

* email pass added to yml file

* Readme updated

* Readme updated

* Coverage table updated

---------

Co-authored-by: Rushikesh Tayade <[email protected]>
  • Loading branch information
ruuushhh and Rushikesh Tayade authored Mar 13, 2023
1 parent e7be04c commit 80f2687
Show file tree
Hide file tree
Showing 50 changed files with 1,105 additions and 50 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source = netsuitesdk/
omit = ./venv/*, tests/*, netsuitesdk/api/billing_account.py, netsuitesdk/api/credit_memos.py, netsuitesdk/api/custom_lists.py, netsuitesdk/api/vendor_credits.py, netsuitesdk/api/usage.py, netsuitesdk/api/invoices.py, netsuitesdk/api/terms.py, netsuitesdk/api/custom_segments.py
39 changes: 39 additions & 0 deletions .github/workflows/pytest_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Continuous Integration

on:
pull_request:
types: [assigned, opened, synchronize, reopened]

jobs:
pytest:
runs-on: ubuntu-latest
environment: CI Environment
steps:
- uses: actions/checkout@v2
continue-on-error: true
- name: Run Tests
env:
NS_ACCOUNT: ${{ secrets.NS_ACCOUNT }}
NS_CONSUMER_KEY: ${{ secrets.NS_CONSUMER_KEY }}
NS_CONSUMER_SECRET: ${{ secrets.NS_CONSUMER_SECRET }}
NS_TOKEN_KEY: ${{ secrets.NS_TOKEN_KEY }}
NS_TOKEN_SECRET: ${{ secrets.NS_TOKEN_SECRET }}
NS_APPID: ${{ secrets.NS_APPID }}
NS_EMAIL: ${{ secrets.NS_EMAIL }}
NS_PASSWORD: ${{ secrets.NS_PASSWORD }}
run: |
pip install -r requirements.txt && pip install pytest pytest-coverage
python -m pytest test/ --cov --junit-xml=test-reports/report.xml --cov-report=term-missing --cov-fail-under=85 | tee pytest-coverage.txt
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV
echo "${{ env.STATUS }}"
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
if: ${{ always() && github.ref != 'refs/heads/master' }}
with:
create-new-comment: true
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./test-reports/report.xml
- name: Evaluate Coverage
if: ${{ (env.STATUS == 'FAIL') || (env.FAILED > 0) }}
run: exit 1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Dockerfile
# test_files
dry_run.py
test_*
!test/*/*
!test/*

# IDEs
.DS_Store
Expand Down Expand Up @@ -121,6 +123,7 @@ venv.bak/
.mypy_cache/

test.py
secrets.sh

make_mock.py
private/
Expand Down
60 changes: 48 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ export NS_TOKEN_KEY=xxxx
export NS_TOKEN_SECRET=xxxx
python -m pytest test/integration
```
Currently the code coverage is at 90%

To run integration tests on a newly added / modified file

```python
python -m pytest -vv test/integration/test_filename.py;

```

## Code coverage
Expand All @@ -238,16 +246,44 @@ To get code coverage report, run this command:
python -m pytest --cov=netsuitesdk

<snipped output>
Name Stmts Miss Cover
---------------------------------------------------
netsuitesdk/__init__.py 5 0 100%
netsuitesdk/client.py 343 198 42%
netsuitesdk/constants.py 3 0 100%
netsuitesdk/exceptions.py 14 5 64%
netsuitesdk/netsuite_types.py 2 0 100%
netsuitesdk/utils.py 47 19 60%
---------------------------------------------------
TOTAL 414 222 46%
Name Stmts Miss Cover
----------------------------------------------------------------------------
netsuitesdk/__init__.py 4 0 100%
netsuitesdk/api/__init__.py 0 0 100%
netsuitesdk/api/accounts.py 6 0 100%
netsuitesdk/api/adv_inter_company_journal_entries.py 7 0 100%
netsuitesdk/api/base.py 90 9 90%
netsuitesdk/api/classifications.py 6 0 100%
netsuitesdk/api/currencies.py 10 0 100%
netsuitesdk/api/custom_record_types.py 11 0 100%
netsuitesdk/api/custom_records.py 17 0 100%
netsuitesdk/api/customers.py 21 0 100%
netsuitesdk/api/departments.py 6 0 100%
netsuitesdk/api/employees.py 34 0 100%
netsuitesdk/api/expense_categories.py 6 0 100%
netsuitesdk/api/expense_reports.py 58 2 97%
netsuitesdk/api/files.py 23 0 100%
netsuitesdk/api/folders.py 17 0 100%
netsuitesdk/api/journal_entries.py 41 0 100%
netsuitesdk/api/locations.py 6 0 100%
netsuitesdk/api/price_level.py 6 0 100%
netsuitesdk/api/projects.py 6 0 100%
netsuitesdk/api/subsidiaries.py 6 0 100%
netsuitesdk/api/tax_groups.py 6 0 100%
netsuitesdk/api/tax_items.py 6 0 100%
netsuitesdk/api/vendor_bills.py 55 1 98%
netsuitesdk/api/vendor_payments.py 46 1 98%
netsuitesdk/api/vendors.py 21 0 100%
netsuitesdk/connection.py 68 0 100%
netsuitesdk/internal/__init__.py 0 0 100%
netsuitesdk/internal/client.py 305 79 74%
netsuitesdk/internal/constants.py 4 0 100%
netsuitesdk/internal/exceptions.py 16 3 81%
netsuitesdk/internal/netsuite_types.py 2 0 100%
netsuitesdk/internal/utils.py 40 4 90%
----------------------------------------------------------------------------
TOTAL 950 99 90%

```

To get an html report, run this command:
Expand All @@ -256,7 +292,7 @@ To get an html report, run this command:
python -m pytest --cov=netsuitesdk --cov-report html:cov_html
```

We want to maintain code coverage of more than 95% for this project at all times.
We want to maintain code coverage of more than 90% for this project at all times.

## Documentation
Documentation can be found in the docs/_build/html folder (open index.html) and soon in readthedocs.
Expand All @@ -265,4 +301,4 @@ as well as `make html`

## Contributions

We are actively accepting contributions. Please mail [email protected] if you wish to collaborate on this.
We are actively accepting contributions. Please mail [email protected] if you wish to collaborate on this. (Please write test cases for new additions.)
3 changes: 3 additions & 0 deletions netsuitesdk/api/employees.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def post(self, data) -> OrderedDict:

employee['workCalendar'] = self.ns_client.RecordRef(**(data['workCalendar']))

if 'defaultAcctCorpCardExp' in data and data['defaultAcctCorpCardExp']:
employee['defaultAcctCorpCardExp'] = self.ns_client.RecordRef(**(data['defaultAcctCorpCardExp']))

if 'entityId' in data:
employee['entityId'] = data['entityId']

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zeep==3.4.0
pytest==5.2.4
pytest==7.2.1
pytest-cov==2.8.1
pytest-mock==1.11.2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@
"type": "account"
},
"credit": 500,
"memo": "Testing JournalEntry via Fyle SDK 3"
"memo": "Testing JournalEntry via Fyle SDK 3",
"customFieldList": [
{
"type": "String",
"value": "NetsuiteSDK test field"
},
{
"type": "Select",
"value": "45"
}
]
},
{
"lineSubsidiary": {
Expand All @@ -48,6 +58,16 @@
"type": "account"
},
"debit": 500,
"customFieldList": [
{
"type": "String",
"value": "NetsuiteSDK test field"
},
{
"type": "Select",
"value": "45"
}
],
"memo": "Testing JournalEntry via Fyle SDK 3"
},
{
Expand All @@ -64,6 +84,16 @@
"type": "account"
},
"credit": 500,
"customFieldList": [
{
"type": "String",
"value": "NetsuiteSDK test field"
},
{
"type": "Select",
"value": "45"
}
],
"memo": "Testing JournalEntry via Fyle SDK 3"
},
{
Expand All @@ -80,6 +110,16 @@
"type": "account"
},
"debit": 500,
"customFieldList": [
{
"type": "String",
"value": "NetsuiteSDK test field"
},
{
"type": "Select",
"value": "45"
}
],
"memo": "Testing JournalEntry via Fyle SDK 3"
}
],
Expand Down
36 changes: 36 additions & 0 deletions test/integration/data/billing_account/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"billingSchedule": {
"externalId": null,
"internalId": 1,
"type": "billingSchedule"
},
"cashSaleForm": null,
"class": null,
"createdBy": null,
"createdDate": null,
"currency": {
"name": "USA",
"internalId": null,
"externalId": null,
"type": "currency"
},
"customer": {
"externalId": null,
"internalId": 1,
"type": "customer"
},
"customForm": null,
"department": null,
"frequency": null,
"inactive": null,
"invoiceForm": null,
"lastBillCycleDate": null,
"lastBillDate": null,
"location": null,
"memo": "Testing BillingAccounts using Fyle SDK",
"name": "Test Case Account",
"nextBillCycleDate": null,
"startDate": "2022-07-21T17:32:28Z",
"subsidiary": null,
"externalId": "1237"
}
81 changes: 81 additions & 0 deletions test/integration/data/credit_memo/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"externalId": "1237",
"account": null,
"altHandlingCost": null,
"altShippingCost": null,
"amountPaid": null,
"amountRemaining": null,
"autoApply": null,
"billAddressList": null,
"billingAddress": null,
"class": null,
"createdDate": null,
"createdFrom": null,
"currency": null,
"currencyName": null,
"customForm": null,
"deferredRevenue": null,
"department": null,
"discountItem": null,
"discountRate": null,
"discountTotal": null,
"email": null,
"entityTaxRegNum": null,
"estGrossProfit": null,
"estGrossProfitPercent": null,
"excludeCommission": null,
"fax": null,
"handlingCost": null,
"handlingTax1Rate": null,
"handlingTax2Rate": null,
"handlingTaxCode": null,
"isMultiShipTo": null,
"isTaxable": null,
"itemList": [],
"job": null,
"lastModifiedDate": null,
"leadSource": null,
"location":null,
"memo": "Testing CreditMemos using Fyle SDK",
"nexus": null,
"partner": null,
"postingPeriod": null,
"promoCode": null,
"recognizedRevenue": null,
"revenueStatus": null,
"revRecOnRevCommitment": null,
"shipMethod": null,
"shippingCost": null,
"shippingTax1Rate": null,
"shippingTax2Rate": null,
"shippingTaxCode": null,
"source": null,
"status": null,
"subsidiary": null,
"subsidiaryTaxRegNum": null,
"subTotal": null,
"tax2Total": null,
"taxDetailsOverride": null,
"taxItem": null,
"taxPointDate": null,
"taxRate": null,
"taxRegOverride": null,
"taxTotal": null,
"toBeEmailed": null,
"toBeFaxed": null,
"toBePrinted": null,
"total": null,
"totalCostEstimate": null,
"tranDate": null,
"tranId": null,
"tranIsVsoeBundle": null,
"unapplied": null,
"vatRegNum": null,
"vsoeAutoCalc": null,
"entity": {
"name": null,
"internalId": "1",
"externalId": null,
"type": "vendor"
}
}
Loading

0 comments on commit 80f2687

Please sign in to comment.