Skip to content

Commit

Permalink
Merge pull request #249 from bcgov/development
Browse files Browse the repository at this point in the history
Merge changes to Test for /business .
  • Loading branch information
pwei1018 authored Jun 18, 2020
2 parents a8dc837 + 59473f3 commit 830419f
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 347 deletions.
3 changes: 2 additions & 1 deletion codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ coverage:
round: down
range: "70...100"
status:
patch: off
patch: no
project:
default: off
backend:
target: 80%
threshold: 5%
flags:
- payapi
- bcolapi
Expand Down
1 change: 0 additions & 1 deletion pay-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ To prepare your local database:
## Openshift Environment

View the [document](https://github.com/bcgov/sbc-auth/blob/development/docs/build-deploy.md).

10 changes: 8 additions & 2 deletions pay-api/logging.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[loggers]
keys=root,api
keys=root,api,tracing

[handlers]
keys=console
Expand All @@ -17,6 +17,12 @@ handlers=console
qualname=api
propagate=0

[logger_tracing]
level=ERROR
handlers=console
qualname=jaeger_tracing
propagate=0

[handler_console]
class=StreamHandler
level=DEBUG
Expand All @@ -25,4 +31,4 @@ args=(sys.stdout,)

[formatter_simple]
format=%(asctime)s - %(name)s - %(levelname)s in %(module)s:%(filename)s:%(lineno)d - %(funcName)s: %(message)s
datefmt=
datefmt=
8 changes: 3 additions & 5 deletions pay-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask-Caching==1.9.0
Flask-Migrate==2.5.3
Flask-Moment==0.9.0
Flask-Moment==0.10.0
Flask-SQLAlchemy==2.4.3
Flask-Script==2.0.6
Flask==1.1.2
Expand All @@ -15,7 +15,7 @@ asyncio-nats-client==0.10.0
asyncio-nats-streaming==0.4.0
attrs==19.1.0
blinker==1.4
certifi==2020.4.5.1
certifi==2020.4.5.2
chardet==3.0.4
click==7.1.2
croniter==0.3.32
Expand All @@ -26,7 +26,6 @@ flask-marshmallow==0.11.0
flask-restplus==0.13.0
gunicorn==20.0.4
idna==2.9
importlib-metadata==1.6.0
itsdangerous==1.1.0
jaeger-client==4.3.0
jsonschema==3.2.0
Expand All @@ -44,12 +43,11 @@ python-editor==1.0.4
python-jose==3.1.0
pytz==2020.1
requests==2.23.0
rsa==4.0
rsa==4.2
sentry-sdk==0.14.4
six==1.15.0
threadloop==1.0.2
thrift==0.13.0
tornado==6.0.4
urllib3==1.25.9
zipp==3.1.0
-e git+https://github.com/bcgov/sbc-common-components.git#egg=sbc-common-components-1.0.0&subdirectory=python
4 changes: 4 additions & 0 deletions pay-api/src/pay_api/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ def _remove_deleted_lines(self, data, many): # pylint: disable=unused-argument,
if 'line_items' in data and not data.get('line_items'):
data.pop('line_items')

# do not include temproary business identifier
if data.get('business_identifier', None) and data.get('business_identifier').startswith('T'):
data.pop('business_identifier')

return data
29 changes: 29 additions & 0 deletions pay-api/tests/unit/services/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_invoice_saved_from_new(session):
assert invoice.paid is None
assert invoice.payment_line_items is not None
assert invoice.folio_number is not None
assert invoice.business_identifier is not None


def test_invoice_invalid_lookup(session):
Expand Down Expand Up @@ -115,3 +116,31 @@ def test_invoice_find_by_invalid_payment_id(session):

assert invoice is not None
assert invoice.id is None


def test_invoice_with_temproary_business_identifier(session):
"""Assert that the invoice dictionary is not include temproary business identifier."""
payment_account = factory_payment_account()
payment = factory_payment()
payment_account.save()
payment.save()
i = factory_invoice(payment=payment, payment_account=payment_account, business_identifier='Tzxcasd')
i.save()
fee_schedule = FeeSchedule.find_by_filing_type_and_corp_type('CP', 'OTANN')
line = factory_payment_line_item(i.id, fee_schedule_id=fee_schedule.fee_schedule_id)
line.save()
invoice = Invoice_service.find_by_id(i.id, skip_auth_check=True)
assert invoice is not None
assert invoice.id is not None
assert invoice.payment_id is not None
assert invoice.invoice_status_code is not None
assert invoice.refund is None
assert invoice.payment_date is None
assert invoice.total is not None
assert invoice.paid is None
assert invoice.payment_line_items is not None
assert invoice.folio_number is not None
assert invoice.business_identifier is not None
invoice_dict = invoice.asdict()
print(invoice_dict)
assert invoice_dict.get('business_identifier') is None
2 changes: 1 addition & 1 deletion pay-api/tests/unit/services/test_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_create_receipt_with_invoice(session, public_user_mock):
payment = factory_payment()
payment_account.save()
payment.save()
invoice = factory_invoice(payment, payment_account)
invoice = factory_invoice(payment, payment_account, service_fees=1.5)
invoice.save()
factory_invoice_reference(invoice.id).save()
fee_schedule = FeeSchedule.find_by_filing_type_and_corp_type('CP', 'OTANN')
Expand Down
6 changes: 4 additions & 2 deletions pay-api/tests/utilities/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def factory_payment(

def factory_invoice(payment: Payment, payment_account: str, status_code: str = InvoiceStatus.CREATED.value,
corp_type_code='CP',
business_identifier: str = 'CP0001234'):
business_identifier: str = 'CP0001234',
service_fees: float = 0.0):
"""Factory."""
bcol_account_id = None
credit_account_id = None
Expand All @@ -309,7 +310,8 @@ def factory_invoice(payment: Payment, payment_account: str, status_code: str = I
created_on=datetime.now(),
business_identifier=business_identifier,
corp_type_code=corp_type_code,
folio_number='1234567890'
folio_number='1234567890',
service_fees=service_fees
)


Expand Down
Loading

0 comments on commit 830419f

Please sign in to comment.