|
1 | | -from io import StringIO |
| 1 | +# from io import StringIO |
2 | 2 |
|
3 | | -import pytest |
4 | | -from etl_utils.ldif.ldif import parse_ldif |
5 | | -from etl_utils.ldif.model import DistinguishedName |
6 | | -from sds.domain.changelog import ChangelogRecord |
7 | | -from sds.domain.parse import parse_sds_record |
8 | | - |
9 | | -from etl.sds.tests.constants import EtlTestDataPath |
| 3 | +# from etl_utils.ldif.ldif import parse_ldif |
| 4 | +# from etl_utils.ldif.model import DistinguishedName |
| 5 | +# from sds.domain.changelog import ChangelogRecord |
| 6 | +# from sds.domain.parse import parse_sds_record |
10 | 7 |
|
11 | 8 |
|
12 | 9 | # all files listed here get downloaded to the paths listed in 'test_data_paths' |
13 | | -@pytest.mark.s3(EtlTestDataPath.CHANGELOG) |
14 | | -def test_changelog_model_against_changelog_data(test_data_paths): |
15 | | - (ldif_path,) = test_data_paths |
16 | | - |
17 | | - ldif_lines = parse_ldif(file_opener=open, path_or_data=ldif_path) |
18 | | - |
19 | | - # Implicit check that one changelog line is expected |
20 | | - ((distinguished_name, record),) = ldif_lines |
21 | | - |
22 | | - # Implicit check that it parses |
23 | | - changelog_record = ChangelogRecord( |
24 | | - _distinguished_name=distinguished_name, |
25 | | - **record, |
26 | | - ) |
27 | | - |
28 | | - # Check that the record has been parsed correctly |
29 | | - assert changelog_record.distinguished_name.change_number == "75852519" |
30 | | - assert changelog_record.distinguished_name.common_name == "changelog" |
31 | | - assert changelog_record.distinguished_name.organisation == "nhs" |
32 | | - |
33 | | - assert changelog_record.object_class == "changeLogEntry" |
34 | | - assert ( |
35 | | - changelog_record.change_number |
36 | | - == changelog_record.distinguished_name.change_number |
37 | | - ) |
38 | | - assert changelog_record.change_time == "20240116173441Z" |
39 | | - assert changelog_record.change_type == "add" |
40 | | - assert changelog_record.target_distinguished_name == DistinguishedName( |
41 | | - parts=(("o", "nhs"), ("ou", "services"), ("uniqueidentifier", "200000042019")) |
42 | | - ) |
| 10 | +# @pytest.mark.s3(EtlTestDataPath.CHANGELOG) Uncomment this when archived |
| 11 | +# def test_changelog_model_against_changelog_data(test_data_paths): |
| 12 | +# (ldif_path,) = test_data_paths |
| 13 | + |
| 14 | +# ldif_lines = parse_ldif(file_opener=open, path_or_data=ldif_path) |
| 15 | + |
| 16 | +# # Implicit check that one changelog line is expected |
| 17 | +# ((distinguished_name, record),) = ldif_lines |
| 18 | + |
| 19 | +# # Implicit check that it parses |
| 20 | +# changelog_record = ChangelogRecord( |
| 21 | +# _distinguished_name=distinguished_name, |
| 22 | +# **record, |
| 23 | +# ) |
| 24 | + |
| 25 | +# # Check that the record has been parsed correctly |
| 26 | +# assert changelog_record.distinguished_name.change_number == "75852519" |
| 27 | +# assert changelog_record.distinguished_name.common_name == "changelog" |
| 28 | +# assert changelog_record.distinguished_name.organisation == "nhs" |
| 29 | + |
| 30 | +# assert changelog_record.object_class == "changeLogEntry" |
| 31 | +# assert ( |
| 32 | +# changelog_record.change_number |
| 33 | +# == changelog_record.distinguished_name.change_number |
| 34 | +# ) |
| 35 | +# assert changelog_record.change_time == "20240116173441Z" |
| 36 | +# assert changelog_record.change_type == "add" |
| 37 | +# assert changelog_record.target_distinguished_name == DistinguishedName( |
| 38 | +# parts=(("o", "nhs"), ("ou", "services"), ("uniqueidentifier", "200000042019")) |
| 39 | +# ) |
43 | 40 |
|
44 | 41 |
|
45 | 42 | # all files listed here get downloaded to the paths listed in 'test_data_paths' |
46 | | -@pytest.mark.s3(EtlTestDataPath.CHANGELOG) |
47 | | -def test_changelog_changes_are_valid_ldif(test_data_paths): |
48 | | - (ldif_path,) = test_data_paths |
49 | | - |
50 | | - ldif_lines = parse_ldif(file_opener=open, path_or_data=ldif_path) |
51 | | - |
52 | | - # Implicit check that one changelog line is expected |
53 | | - ((distinguished_name, record),) = ldif_lines |
54 | | - |
55 | | - # Implicit check that it parses |
56 | | - changelog_record = ChangelogRecord( |
57 | | - _distinguished_name=distinguished_name, |
58 | | - **record, |
59 | | - ) |
60 | | - |
61 | | - # Check that the change itself is valid LDIF |
62 | | - nested_ldif_lines = list( |
63 | | - parse_ldif( |
64 | | - file_opener=StringIO, path_or_data=changelog_record.changes_as_ldif() |
65 | | - ) |
66 | | - ) |
67 | | - assert len(nested_ldif_lines) == 1 |
68 | | - |
69 | | - # Check that the change is a valid SDS record |
70 | | - ((nested_distinguished_name, nested_record),) = nested_ldif_lines |
71 | | - sds_record = parse_sds_record( |
72 | | - distinguished_name=nested_distinguished_name, record=nested_record |
73 | | - ) |
74 | | - assert sds_record.dict() == { |
75 | | - "change_type": "add", |
76 | | - "description": None, |
77 | | - "nhs_approver_urp": "System", |
78 | | - "nhs_as_acf": None, |
79 | | - "nhs_as_category_bag": None, |
80 | | - "nhs_as_client": {"K81045"}, |
81 | | - "nhs_as_svc_ia": { |
82 | | - "urn:nhs:names:services:gpconnect:fhir:operation:gpc.getcarerecord", |
83 | | - "urn:nhs:names:services:gpconnect:fhir:operation:gpc.registerpatient-1", |
84 | | - "urn:nhs:names:services:gpconnect:fhir:rest:cancel:appointment-1", |
85 | | - "urn:nhs:names:services:gpconnect:fhir:rest:create:appointment-1", |
86 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:appointment-1", |
87 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:location-1", |
88 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:metadata", |
89 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:metadata-1", |
90 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:organization-1", |
91 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:patient-1", |
92 | | - "urn:nhs:names:services:gpconnect:fhir:rest:read:practitioner-1", |
93 | | - "urn:nhs:names:services:gpconnect:fhir:rest:search:organization-1", |
94 | | - "urn:nhs:names:services:gpconnect:fhir:rest:search:patient-1", |
95 | | - "urn:nhs:names:services:gpconnect:fhir:rest:search:patient_appointments-1", |
96 | | - "urn:nhs:names:services:gpconnect:fhir:rest:search:practitioner-1", |
97 | | - "urn:nhs:names:services:gpconnect:fhir:rest:search:slot-1", |
98 | | - "urn:nhs:names:services:gpconnect:fhir:rest:update:appointment-1", |
99 | | - }, |
100 | | - "nhs_date_approved": "20240116173441", |
101 | | - "nhs_date_requested": "20240116173439", |
102 | | - "nhs_id_code": "K81045", |
103 | | - "nhs_mhs_manufacturer_org": "K81045", |
104 | | - "nhs_mhs_party_key": "R3U6M-831547", |
105 | | - "nhs_product_key": "6255", |
106 | | - "nhs_product_name": "Continuum Health GPC", |
107 | | - "nhs_product_version": "Consumer AS", |
108 | | - "nhs_requestor_urp": "uniqueidentifier=865945089569,uniqueidentifier=065150856568,uid=798965609042,ou=people, o=nhs", |
109 | | - "nhs_temp_uid": None, |
110 | | - "object_class": "nhsas", |
111 | | - "unique_identifier": "200000042019", |
112 | | - } |
| 43 | +# @pytest.mark.s3(EtlTestDataPath.CHANGELOG) Uncomment this when archived |
| 44 | +# def test_changelog_changes_are_valid_ldif(test_data_paths): |
| 45 | +# (ldif_path,) = test_data_paths |
| 46 | + |
| 47 | +# ldif_lines = parse_ldif(file_opener=open, path_or_data=ldif_path) |
| 48 | + |
| 49 | +# # Implicit check that one changelog line is expected |
| 50 | +# ((distinguished_name, record),) = ldif_lines |
| 51 | + |
| 52 | +# # Implicit check that it parses |
| 53 | +# changelog_record = ChangelogRecord( |
| 54 | +# _distinguished_name=distinguished_name, |
| 55 | +# **record, |
| 56 | +# ) |
| 57 | + |
| 58 | +# # Check that the change itself is valid LDIF |
| 59 | +# nested_ldif_lines = list( |
| 60 | +# parse_ldif( |
| 61 | +# file_opener=StringIO, path_or_data=changelog_record.changes_as_ldif() |
| 62 | +# ) |
| 63 | +# ) |
| 64 | +# assert len(nested_ldif_lines) == 1 |
| 65 | + |
| 66 | +# # Check that the change is a valid SDS record |
| 67 | +# ((nested_distinguished_name, nested_record),) = nested_ldif_lines |
| 68 | +# sds_record = parse_sds_record( |
| 69 | +# distinguished_name=nested_distinguished_name, record=nested_record |
| 70 | +# ) |
| 71 | +# assert sds_record.dict() == { |
| 72 | +# "change_type": "add", |
| 73 | +# "description": None, |
| 74 | +# "nhs_approver_urp": "System", |
| 75 | +# "nhs_as_acf": None, |
| 76 | +# "nhs_as_category_bag": None, |
| 77 | +# "nhs_as_client": {"K81045"}, |
| 78 | +# "nhs_as_svc_ia": { |
| 79 | +# "urn:nhs:names:services:gpconnect:fhir:operation:gpc.getcarerecord", |
| 80 | +# "urn:nhs:names:services:gpconnect:fhir:operation:gpc.registerpatient-1", |
| 81 | +# "urn:nhs:names:services:gpconnect:fhir:rest:cancel:appointment-1", |
| 82 | +# "urn:nhs:names:services:gpconnect:fhir:rest:create:appointment-1", |
| 83 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:appointment-1", |
| 84 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:location-1", |
| 85 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:metadata", |
| 86 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:metadata-1", |
| 87 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:organization-1", |
| 88 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:patient-1", |
| 89 | +# "urn:nhs:names:services:gpconnect:fhir:rest:read:practitioner-1", |
| 90 | +# "urn:nhs:names:services:gpconnect:fhir:rest:search:organization-1", |
| 91 | +# "urn:nhs:names:services:gpconnect:fhir:rest:search:patient-1", |
| 92 | +# "urn:nhs:names:services:gpconnect:fhir:rest:search:patient_appointments-1", |
| 93 | +# "urn:nhs:names:services:gpconnect:fhir:rest:search:practitioner-1", |
| 94 | +# "urn:nhs:names:services:gpconnect:fhir:rest:search:slot-1", |
| 95 | +# "urn:nhs:names:services:gpconnect:fhir:rest:update:appointment-1", |
| 96 | +# }, |
| 97 | +# "nhs_date_approved": "20240116173441", |
| 98 | +# "nhs_date_requested": "20240116173439", |
| 99 | +# "nhs_id_code": "K81045", |
| 100 | +# "nhs_mhs_manufacturer_org": "K81045", |
| 101 | +# "nhs_mhs_party_key": "R3U6M-831547", |
| 102 | +# "nhs_product_key": "6255", |
| 103 | +# "nhs_product_name": "Continuum Health GPC", |
| 104 | +# "nhs_product_version": "Consumer AS", |
| 105 | +# "nhs_requestor_urp": "uniqueidentifier=865945089569,uniqueidentifier=065150856568,uid=798965609042,ou=people, o=nhs", |
| 106 | +# "nhs_temp_uid": None, |
| 107 | +# "object_class": "nhsas", |
| 108 | +# "unique_identifier": "200000042019", |
| 109 | +# } |
0 commit comments