Skip to content

Commit

Permalink
Updating dates and renaming some files.
Browse files Browse the repository at this point in the history
  • Loading branch information
hfekete committed Dec 20, 2023
1 parent c65631c commit f2c7fa1
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 34 deletions.
9 changes: 4 additions & 5 deletions btr-api/src/btr_api/schemas/significantIndividualsFiling.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
},
"startDate": {
"type": "string",
"format": "date-time"
"format": "date"
},
"endDate": {
"type": "string",
"format": "date-time"
"format": "date"
}
},
"type": "object",
Expand All @@ -104,8 +104,7 @@
"percentOfShares",
"percentOfVotes",
"profile",
"startDate",
"action"
"startDate"
]
},
"significantIndividualFiling": {
Expand All @@ -118,7 +117,7 @@
},
"effectiveDate": {
"type": "string",
"format": "date-time"
"format": "date"
},
"significantIndividuals": {
"items": {
Expand Down
4 changes: 2 additions & 2 deletions btr-api/src/btr_api/services/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from datetime import datetime
from datetime import date

from btr_api.models import Person as PersonModel, Submission as SubmissionModel
from btr_api.services.ownership_details import OwnershipDetailsService
Expand All @@ -43,7 +43,7 @@ class SubmissionService(object):
@staticmethod
def create_submission(submission_dict: dict) -> SubmissionModel:
submission = SubmissionModel()
submission.effective_date = datetime.fromisoformat(submission_dict['effectiveDate'])
submission.effective_date = date.fromisoformat(submission_dict['effectiveDate'])
submission.payload = submission_dict

for significant_individual in submission_dict['significantIndividuals']:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"businessIdentifier": "12345",
"folioNumber": "67890",
"effectiveDate": "2022-01-01T00:00:00Z",
"effectiveDate": "2022-01-01",
"significantIndividuals": [
{
"controlType": {
Expand Down Expand Up @@ -48,8 +48,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"businessIdentifier": "12345",
"folioNumber": "67890",
"effectiveDate": "2022-01-01T00:00:00Z",
"effectiveDate": "2022-01-01",
"significantIndividuals": [
{
"controlType": {
Expand Down Expand Up @@ -48,8 +48,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"businessIdentifier": "12345",
"folioNumber": "67890",
"effectiveDate": "2022-01-01T00:00:00Z",
"effectiveDate": "2022-01-01",
"significantIndividuals": [
{
"controlType": {
Expand Down Expand Up @@ -48,8 +48,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
5 changes: 2 additions & 3 deletions btr-api/tests/mocks/significantIndividualsFiling/valid.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"businessIdentifier": "12345",
"folioNumber": "67890",
"effectiveDate": "2022-01-01T00:00:00Z",
"effectiveDate": "2022-01-01",
"significantIndividuals": [
{
"controlType": {
Expand Down Expand Up @@ -48,8 +48,7 @@
"taxNumber": "987654321",
"uuid": "e2dd8f31-a097-4c8a-9f92-76e6f92f63f4"
},
"startDate": "2022-01-01T00:00:00Z",
"action": "add"
"startDate": "2022-01-01"
}
],
"certified": true
Expand Down
9 changes: 0 additions & 9 deletions btr-api/tests/unit/resources/test_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
import pytest


def test_list_all_schemas(client, session):
expected_available_schemas = ['significantIndividualsFiling']
rv = client.get('/json-schemas')

json_data = rv.get_json()
assert rv.status_code == HTTPStatus.OK
assert json_data['schemas'] == expected_available_schemas


@pytest.mark.parametrize(
"test_name, schema_name, expected_status",
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(
"Invalid date format -- effectiveDate",
"effective_date_invalid_format.json",
"'2022-01-01----' is not a 'date-time'"
"'2022-01-01----' is not a 'date'"
),
(
"Address Line 1 to long",
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_invalid_significant_individuals_filing_schema(
assert expected_error in [error["message"] for error in errors]


def test_valid_significant_individuals_filing_schema(client, session):
def test_valid_significant_individuals_filing_schema():
current_dir = os.path.dirname(__file__)

with open(
Expand All @@ -59,5 +59,6 @@ def test_valid_significant_individuals_filing_schema(client, session):
data = json.load(file)
ss = SchemaService()
[valid, errors] = ss.validate(schema_name="significantIndividualsFiling", data=data)
print(errors)
assert valid is True
assert len(errors) == 0

0 comments on commit f2c7fa1

Please sign in to comment.