Skip to content

Commit dbd2af3

Browse files
Unit tests to test data agreement model
Signed-off-by: George J Padayatti <[email protected]>
1 parent 3307d6e commit dbd2af3

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

mydata_did/v1_0/models/tests/__init__.py

Whitespace-only changes.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from asynctest import TestCase as AsyncTestCase
2+
3+
from ..data_agreement_model import DataAgreementV1Schema, DataAgreementV1
4+
from marshmallow.exceptions import ValidationError
5+
6+
7+
class TestDataAgreementV1Model(AsyncTestCase):
8+
9+
def test_data_agreement_model(self):
10+
data_agreement_dict = {
11+
"@context": "https://raw.githubusercontent.com/decentralised-dataexchange/automated-data-agreements/main/interface-specs/data-agreement-schema/v1/data-agreement-schema-context.jsonld",
12+
"data_controller_name": "XYZ Corp",
13+
"data_controller_url": "https://xyz.com",
14+
"purpose": "Issuance of parking permit",
15+
"purpose_description": "Issuance of parking permit",
16+
"lawful_basis": "consent",
17+
"method_of_use": "data-source",
18+
"data_policy": {
19+
"data_retention_period": 365,
20+
"policy_URL": "https://clarifyhealth.com/privacy-policy/",
21+
"jurisdiction": "EU",
22+
"industry_sector": "Retail",
23+
"geographic_restriction": "EU",
24+
"storage_location": "EU"
25+
},
26+
"personal_data": [
27+
{
28+
"attribute_name": "First Name",
29+
"attribute_sensitive": True,
30+
"attribute_category": "Biographic",
31+
"attribute_description": "First name of the person"
32+
}
33+
],
34+
"dpia": {
35+
"dpia_date": "2022-02-13T15:25:18.117255+00:00",
36+
"dpia_summary_url": "https://org.com/dpia_results.html"
37+
}
38+
}
39+
40+
data_agreement: DataAgreementV1 = DataAgreementV1Schema().load(data_agreement_dict)
41+
42+
assert data_agreement.pii_controller_name == "XYZ Corp"
43+
44+
assert len(data_agreement.personal_data) == 1
45+
46+
self.assertIsNone(
47+
data_agreement.personal_data[0].attribute_id, "Attribute ID should be None")
48+
49+
data_agreement_dict.pop("data_controller_name")
50+
with self.assertRaises(ValidationError) as ctx:
51+
data_agreement: DataAgreementV1 = DataAgreementV1Schema().load(data_agreement_dict)
52+
53+
self.assertTrue(
54+
"Missing data for required field." in str(ctx.exception))

0 commit comments

Comments
 (0)