Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions legal-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def post_comments(identifier):
try:
comment = Comment()
comment.comment = json_input["comment"]["comment"]
comment.comment_type = Comment.CommentType.STAFF
comment.staff_id = user.id
comment.business_id = business.id
comment.timestamp = datetime.now(UTC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def post_filing_comments(identifier, filing_id):
try:
comment = Comment()
comment.comment = json_input["comment"]["comment"]
comment.comment_type = Comment.CommentType.STAFF
comment.staff_id = user.id
comment.filing_id = filing_id
comment.timestamp = datetime.now(UTC)
Expand Down
1 change: 1 addition & 0 deletions legal-api/tests/unit/core/test_filing_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def load_ledger(business, founding_date):
for c in range(i):
comment = Comment()
comment.comment = f'this comment {c}'
comment.comment_type = Comment.CommentType.STAFF
f.comments.append(comment)
f.save()
i += 1
Expand Down
2 changes: 2 additions & 0 deletions legal-api/tests/unit/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def factory_business_comment(business: Business = None, comment_text: str = 'som

c = Comment()
c.business_id = business.id
c.comment_type = Comment.CommentType.STAFF
c.timestamp = EPOCH_DATETIME
c.comment = comment_text
if user:
Expand All @@ -382,6 +383,7 @@ def factory_comment(
c.filing_id = filing.id
c.timestamp = EPOCH_DATETIME
c.comment = comment_text
c.comment_type = Comment.CommentType.STAFF
if user:
c.staff_id = user.id
c.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def test_ledger_comment_count(app, session, client, jwt, monkeypatch, mock_drs_s
business, filing_storage = ledger_element_setup_help(identifier)
for c in range(number_of_comments):
comment = Comment()
comment.comment_type = Comment.CommentType.STAFF
comment.comment = f'this comment {c}'
filing_storage.comments.append(comment)
filing_storage.save()
Expand Down
9 changes: 8 additions & 1 deletion legal-api/tests/unit/resources/v2/test_filing_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from freezegun import freeze_time

from business_common.utils import datetime
from business_model.models import User
from business_model.models import Comment, User
from legal_api.services.authz import BASIC_USER, STAFF_ROLE
from registry_schemas.example_data import ANNUAL_REPORT, COMMENT_FILING
from tests.unit.models import factory_business, factory_comment, factory_filing
Expand Down Expand Up @@ -166,6 +166,9 @@ def test_post_comment(session, client, jwt):
b = factory_business('CP1111111')
f = factory_filing(b, ANNUAL_REPORT)

pre_comments = f.comments.all()
assert len(pre_comments) == 0

json_data = copy.deepcopy(SAMPLE_JSON_DATA)
json_data['comment']['filingId'] = f.id

Expand All @@ -174,6 +177,10 @@ def test_post_comment(session, client, jwt):
headers=create_header(jwt, [STAFF_ROLE]))

assert HTTPStatus.CREATED == rv.status_code

comments = f.comments.all()
assert len(comments) == 1
assert comments[0].comment_type == Comment.CommentType.STAFF


def test_post_comment_missing_filingid_error(session, client, jwt):
Expand Down
38 changes: 19 additions & 19 deletions queue_services/business-filer/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ def process(business: Business, amalgamation_out_filing: Filing, filing: dict, f
"amalgamationOutDate": amalgamation_out_date_str
}

# add comment to the filing
# add filing comment to the filing
amalgamation_out_filing.comments.append(
Comment(
comment=details,
comment_type=Comment.CommentType.FILING,
staff_id=amalgamation_out_filing.submitter_id
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def process(business: Business, cco_filing: Filing, filing: dict, filing_meta: F
cco_filing.comments.append(
Comment(
comment=details,
comment_type=Comment.CommentType.FILING,
staff_id=cco_filing.submitter_id
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def process(business: Business, continuation_out_filing: Filing, filing: dict, f
continuation_out_filing.comments.append(
Comment(
comment=details,
comment_type=Comment.CommentType.FILING,
staff_id=continuation_out_filing.submitter_id
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def process(correction_filing: Filing, filing: dict, filing_meta: FilingMeta, bu
Comment(
comment=f"This filing was corrected on "
f"{correction_filing.filing_date.astimezone(local_timezone).date().isoformat()}.",
comment_type=Comment.CommentType.FILING,
staff_id=correction_filing.submitter_id
)
)
Expand All @@ -70,6 +71,7 @@ def process(correction_filing: Filing, filing: dict, filing_meta: FilingMeta, bu
correction_filing.comments.append(
Comment(
comment=filing["correction"]["comment"],
comment_type=Comment.CommentType.FILING,
staff_id=correction_filing.submitter_id
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import copy
import random

from datetime import datetime, timezone
from business_model.models import Business, Filing

from registry_schemas.example_data import AMALGAMATION_OUT, FILING_TEMPLATE
from business_model.models import Business, Comment, Filing
from business_model.utils.legislation_datetime import LegislationDatetime
from registry_schemas.example_data import AMALGAMATION_OUT, FILING_TEMPLATE

from business_filer.filing_meta import FilingMeta
from business_filer.filing_processors import amalgamation_out
Expand Down Expand Up @@ -69,3 +67,4 @@ def tests_filer_amalgamation_out(app, session):
filing_comments = final_filing.comments.all()
assert len(filing_comments) == 1
assert filing_comments[0].comment == details
assert filing_comments[0].comment_type == Comment.CommentType.FILING
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from datetime import datetime, timezone

import pytest
from business_model.models import ConsentContinuationOut, Filing
from business_model.models import Comment, ConsentContinuationOut, Filing
from business_filer.common.legislation_datetime import LegislationDatetime
from registry_schemas.example_data import CONSENT_CONTINUATION_OUT, FILING_TEMPLATE

Expand Down Expand Up @@ -112,3 +112,8 @@ def tests_filer_consent_continuation_out(app, session, mocker, test_name, effect
assert final_filing.meta_data['consentContinuationOut']['region'] == \
filing_json['filing']['consentContinuationOut']['foreignJurisdiction']['region']
assert final_filing.meta_data['consentContinuationOut']['expiry'] == expiry_date_utc.isoformat()

filing_comments = final_filing.comments.all()
assert len(filing_comments) == 1
assert filing_comments[0].comment == filing_json['filing']['consentContinuationOut']['details']
assert filing_comments[0].comment_type == Comment.CommentType.FILING
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
import copy
import random

from datetime import datetime, timezone
from business_model.models import Business, Document, Filing

from business_model.models import Business, Comment, Document, Filing
from registry_schemas.example_data import CONTINUATION_OUT, FILING_TEMPLATE
from business_filer.common.legislation_datetime import LegislationDatetime

from business_filer.common.legislation_datetime import LegislationDatetime
from business_filer.filing_meta import FilingMeta
from business_filer.filing_processors import continuation_out
from business_filer.filing_processors.continuation_out import CONTINUATION_OUT_DOCUMENT_TYPE
Expand Down Expand Up @@ -127,6 +125,11 @@ def tests_filer_continuation_out_uploaded_documents(app, session):
assert len(meta_documents) == len(uploaded_documents)
for file in uploaded_documents:
assert file in meta_documents

filing_comments = final_filing.comments.all()
assert len(filing_comments) == 1
assert filing_comments[0].comment == filing_json['filing']['continuationOut']['details']
assert filing_comments[0].comment_type == Comment.CommentType.FILING


def tests_filer_continuation_out_no_uploaded_documents(app, session):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import pytest
import random

from business_model.models import Business, Filing, PartyRole
from business_model.models import Business, Comment, Filing, PartyRole
from registry_schemas.example_data import (
CHANGE_OF_DIRECTORS,
CHANGE_OF_RECEIVERS,
Expand Down Expand Up @@ -65,6 +65,23 @@ def _assert_common_data(business: Business, filing: Filing):
assert filing.transaction_id
assert filing.business_id == business.id
assert filing.status == Filing.Status.COMPLETED.value


def _assert_correction_comments(filing: Filing):
"""Assert the expected correction comments were added."""
original_filing = Filing.find_by_id(filing.filing_json["filing"]["correction"]["correctedFilingId"])

filing_comments = filing.comments.all()
original_filing_comments = original_filing.comments.all()

assert len(filing_comments) == 1
assert len(original_filing_comments) == 1

assert original_filing_comments[0].comment_type == Comment.CommentType.FILING
assert filing_comments[0].comment_type == Comment.CommentType.FILING

assert "This filing was corrected on " in original_filing_comments[0].comment
assert filing_comments[0].comment == filing.filing_json["filing"]["correction"]["comment"]


def _get_filing(filing_type: str, data: dict, identifier = 'BC1234567', needs_template = True):
Expand Down Expand Up @@ -129,6 +146,7 @@ def test_process_correction_filing_with_relationships(app, session, mocker, fili
correction_processed_filing: Filing = Filing.find_by_id(correction_filing_rec.id)
# assert changes
_assert_common_data(business, correction_processed_filing)
_assert_correction_comments(correction_processed_filing)
assert correction_processed_filing.lear_only == expected_lear_only
party_roles: list[PartyRole] = business.party_roles.all()
assert len(party_roles) == 2
Expand Down
Loading