@@ -36,10 +36,16 @@ async def setUp(self):
36
36
async def insert (self , participant_id , org , external_id ):
37
37
"""Directly insert into participant_external_id table"""
38
38
query = """
39
- INSERT INTO participant_external_id (project, participant_id, name, external_id)
40
- VALUES (:project, :id, :org, :external_id)
39
+ INSERT INTO participant_external_id (project, participant_id, name, external_id, audit_log_id )
40
+ VALUES (:project, :id, :org, :external_id, :audit_log_id )
41
41
"""
42
- values = {'project' : self .project_id , 'id' : participant_id , 'org' : org , 'external_id' : external_id }
42
+ values = {
43
+ 'project' : self .project_id ,
44
+ 'id' : participant_id ,
45
+ 'org' : org ,
46
+ 'external_id' : external_id ,
47
+ 'audit_log_id' : await self .audit_log_id (),
48
+ }
43
49
await self .connection .connection .execute (query , values )
44
50
45
51
@run_as_sync
@@ -53,9 +59,10 @@ async def test_constraints(self):
53
59
with self .assertRaises (IntegrityError ):
54
60
await self .insert (self .p1 .id , 'CONTROL' , 'Maxwell' )
55
61
56
- # Can have eids in lots of organisations, even if the eid duplicates one in a different org
62
+ # Can have eids in lots of organisations, but not if the eid duplicates one in a different org
57
63
await self .insert (self .p1 .id , 'OTHER1' , 'Maxwell' )
58
- await self .insert (self .p1 .id , 'OTHER2' , '86' )
64
+ with self .assertRaises (IntegrityError ):
65
+ await self .insert (self .p1 .id , 'OTHER2' , '86' )
59
66
60
67
# Another participant can't have the same eid
61
68
with self .assertRaises (IntegrityError ):
@@ -76,11 +83,11 @@ async def test_insert(self):
76
83
77
84
result = await self .player .upsert_participant (
78
85
ParticipantUpsertInternal (
79
- external_ids = {PRIMARY_EXTERNAL_ORG : 'P10' , 'A' : 'A1' , 'B' : None , 'C' : 'A1 ' },
86
+ external_ids = {PRIMARY_EXTERNAL_ORG : 'P10' , 'A' : 'A1' , 'B' : None , 'C' : 'C1 ' },
80
87
)
81
88
)
82
89
participants = await self .player .get_participants_by_ids ([result .id ])
83
- self .assertDictEqual (participants [0 ].external_ids , {PRIMARY_EXTERNAL_ORG : 'P10' , 'a' : 'A1' , 'c' : 'A1 ' })
90
+ self .assertDictEqual (participants [0 ].external_ids , {PRIMARY_EXTERNAL_ORG : 'P10' , 'a' : 'A1' , 'c' : 'C1 ' })
84
91
85
92
@run_as_sync
86
93
async def test_update (self ):
@@ -215,10 +222,16 @@ async def setUp(self):
215
222
async def insert (self , sample_id , org , external_id ):
216
223
"""Directly insert into sample_external_id table"""
217
224
query = """
218
- INSERT INTO sample_external_id (project, sample_id, name, external_id)
219
- VALUES (:project, :id, :org, :external_id)
225
+ INSERT INTO sample_external_id (project, sample_id, name, external_id, audit_log_id )
226
+ VALUES (:project, :id, :org, :external_id, :audit_log_id )
220
227
"""
221
- values = {'project' : self .project_id , 'id' : sample_id , 'org' : org , 'external_id' : external_id }
228
+ values = {
229
+ 'project' : self .project_id ,
230
+ 'id' : sample_id ,
231
+ 'org' : org ,
232
+ 'external_id' : external_id ,
233
+ 'audit_log_id' : await self .audit_log_id (),
234
+ }
222
235
await self .connection .connection .execute (query , values )
223
236
224
237
@run_as_sync
@@ -232,9 +245,10 @@ async def test_constraints(self):
232
245
with self .assertRaises (IntegrityError ):
233
246
await self .insert (self .s1 .id , 'CONTROL' , 'Maxwell' )
234
247
235
- # Can have eids in lots of organisations, even if the eid duplicates one in a different org
248
+ # Can have eids in lots of organisations, but not if the eid duplicates one in a different org
236
249
await self .insert (self .s1 .id , 'OTHER1' , 'Maxwell' )
237
- await self .insert (self .s1 .id , 'OTHER2' , '86' )
250
+ with self .assertRaises (IntegrityError ):
251
+ await self .insert (self .s1 .id , 'OTHER2' , '86' )
238
252
239
253
# Another sample can't have the same eid
240
254
with self .assertRaises (IntegrityError ):
@@ -255,11 +269,11 @@ async def test_insert(self):
255
269
256
270
result = await self .slayer .upsert_sample (
257
271
SampleUpsertInternal (
258
- external_ids = {PRIMARY_EXTERNAL_ORG : 'S10' , 'A' : 'A1' , 'B' : None , 'C' : 'A1 ' },
272
+ external_ids = {PRIMARY_EXTERNAL_ORG : 'S10' , 'A' : 'A1' , 'B' : None , 'C' : 'C1 ' },
259
273
)
260
274
)
261
275
sample = await self .slayer .get_sample_by_id (result .id )
262
- self .assertDictEqual (sample .external_ids , {PRIMARY_EXTERNAL_ORG : 'S10' , 'a' : 'A1' , 'c' : 'A1 ' })
276
+ self .assertDictEqual (sample .external_ids , {PRIMARY_EXTERNAL_ORG : 'S10' , 'a' : 'A1' , 'c' : 'C1 ' })
263
277
264
278
@run_as_sync
265
279
async def test_update (self ):
0 commit comments