|
14 | 14 |
|
15 | 15 | import os |
16 | 16 | import pytest |
17 | | -import re |
18 | 17 | import sys |
19 | | -import time |
| 18 | +import uuid |
| 19 | + |
| 20 | +from gcp_devrel.testing import eventually_consistent |
20 | 21 |
|
21 | 22 | # Add datasets for bootstrapping datasets for testing |
22 | 23 | sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa |
|
28 | 29 | project_id = os.environ['GOOGLE_CLOUD_PROJECT'] |
29 | 30 | service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] |
30 | 31 |
|
31 | | -dataset_id = 'test_dataset_{}'.format(int(time.time())) |
32 | | -hl7v2_store_id = 'test_hl7v2_store-{}'.format(int(time.time())) |
| 32 | +dataset_id = 'test_dataset_{}'.format(uuid.uuid4()) |
| 33 | +hl7v2_store_id = 'test_hl7v2_store-{}'.format(uuid.uuid4()) |
33 | 34 | hl7v2_message_file = 'resources/hl7-sample-ingest.json' |
34 | 35 | label_key = 'PROCESSED' |
35 | 36 | label_value = 'TRUE' |
@@ -81,15 +82,20 @@ def test_CRUD_hl7v2_message(test_dataset, test_hl7v2_store, capsys): |
81 | 82 | hl7v2_store_id, |
82 | 83 | hl7v2_message_file) |
83 | 84 |
|
84 | | - hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
85 | | - service_account_json, |
86 | | - project_id, |
87 | | - cloud_region, |
88 | | - dataset_id, |
89 | | - hl7v2_store_id) |
90 | | - |
91 | | - hl7v2_messages_list_to_str = str(hl7v2_messages_list).split('/', 9)[9] |
92 | | - hl7v2_message_id = re.sub('\']', '', hl7v2_messages_list_to_str) |
| 85 | + hl7v2_message_id = "" |
| 86 | + @eventually_consistent.call |
| 87 | + def _(): |
| 88 | + hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
| 89 | + service_account_json, |
| 90 | + project_id, |
| 91 | + cloud_region, |
| 92 | + dataset_id, |
| 93 | + hl7v2_store_id) |
| 94 | + |
| 95 | + assert len(hl7v2_messages_list) > 0 |
| 96 | + hl7v2_message_name = hl7v2_messages_list[0].get('name') |
| 97 | + nonlocal hl7v2_message_id |
| 98 | + hl7v2_message_id = hl7v2_message_name.split('/', 9)[9] |
93 | 99 |
|
94 | 100 | hl7v2_messages.get_hl7v2_message( |
95 | 101 | service_account_json, |
@@ -124,15 +130,20 @@ def test_ingest_hl7v2_message(test_dataset, test_hl7v2_store, capsys): |
124 | 130 | hl7v2_store_id, |
125 | 131 | hl7v2_message_file) |
126 | 132 |
|
127 | | - hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
128 | | - service_account_json, |
129 | | - project_id, |
130 | | - cloud_region, |
131 | | - dataset_id, |
132 | | - hl7v2_store_id) |
133 | | - |
134 | | - hl7v2_messages_list_to_str = str(hl7v2_messages_list).split('/', 9)[9] |
135 | | - hl7v2_message_id = re.sub('\']', '', hl7v2_messages_list_to_str) |
| 133 | + hl7v2_message_id = "" |
| 134 | + @eventually_consistent.call |
| 135 | + def _(): |
| 136 | + hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
| 137 | + service_account_json, |
| 138 | + project_id, |
| 139 | + cloud_region, |
| 140 | + dataset_id, |
| 141 | + hl7v2_store_id) |
| 142 | + |
| 143 | + assert len(hl7v2_messages_list) > 0 |
| 144 | + hl7v2_message_name = hl7v2_messages_list[0].get('name') |
| 145 | + nonlocal hl7v2_message_id |
| 146 | + hl7v2_message_id = hl7v2_message_name.split('/', 9)[9] |
136 | 147 |
|
137 | 148 | hl7v2_messages.get_hl7v2_message( |
138 | 149 | service_account_json, |
@@ -167,15 +178,20 @@ def test_patch_hl7v2_message(test_dataset, test_hl7v2_store, capsys): |
167 | 178 | hl7v2_store_id, |
168 | 179 | hl7v2_message_file) |
169 | 180 |
|
170 | | - hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
171 | | - service_account_json, |
172 | | - project_id, |
173 | | - cloud_region, |
174 | | - dataset_id, |
175 | | - hl7v2_store_id) |
176 | | - |
177 | | - hl7v2_messages_list_to_str = str(hl7v2_messages_list).split('/', 9)[9] |
178 | | - hl7v2_message_id = re.sub('\']', '', hl7v2_messages_list_to_str) |
| 181 | + hl7v2_message_id = "" |
| 182 | + @eventually_consistent.call |
| 183 | + def _(): |
| 184 | + hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
| 185 | + service_account_json, |
| 186 | + project_id, |
| 187 | + cloud_region, |
| 188 | + dataset_id, |
| 189 | + hl7v2_store_id) |
| 190 | + |
| 191 | + assert len(hl7v2_messages_list) > 0 |
| 192 | + hl7v2_message_name = hl7v2_messages_list[0].get('name') |
| 193 | + nonlocal hl7v2_message_id |
| 194 | + hl7v2_message_id = hl7v2_message_name.split('/', 9)[9] |
179 | 195 |
|
180 | 196 | hl7v2_messages.patch_hl7v2_message( |
181 | 197 | service_account_json, |
|
0 commit comments