@@ -1252,6 +1252,57 @@ def test_query_barcode_stats_project_barcodes_with_strip(self):
1252
1252
self .assertEqual ([v ['sample-status' ] for v in response_obj ],
1253
1253
exp_status )
1254
1254
1255
+ def test_query_barcode_stats_multiple_projects (self ):
1256
+ barcodes = ['000005059' , '000005078' , '000005103' ]
1257
+ input_json = json .dumps ({'sample_barcodes' : barcodes })
1258
+
1259
+ response = self .client .post (
1260
+ "api/admin/account_barcode_summary?strip_sampleid=False" ,
1261
+ content_type = 'application/json' ,
1262
+ data = input_json ,
1263
+ headers = MOCK_HEADERS
1264
+ )
1265
+ # an empty string project should be unknown
1266
+ self .assertEqual (200 , response .status_code )
1267
+
1268
+ response_obj = json .loads (response .data )
1269
+ self .assertIn ('samples' , response_obj )
1270
+ response_obj = response_obj ['samples' ]
1271
+ self .assertEqual (len (response_obj ), 3 )
1272
+
1273
+ self .assertEqual ([v ['sampleid' ] for v in response_obj ], barcodes )
1274
+ response_projects = [v ['project' ].split ('; ' ) for v in response_obj ]
1275
+ self .assertEqual (len (response_projects [0 ]), 2 )
1276
+ self .assertEqual (len (response_projects [1 ]), 3 )
1277
+ self .assertEqual (len (response_projects [2 ]), 3 )
1278
+ self .assertTrue (all (
1279
+ projs [0 ] == 'American Gut Project' for projs in response_projects
1280
+ ))
1281
+ # content: should have exactly the same projects
1282
+ self .assertEqual (response_projects [1 ], response_projects [2 ])
1283
+
1284
+ def test_query_barcode_stats_by_project (self ):
1285
+ input_json = json .dumps ({'project_id' : 19 }) # expect 5 barcodes
1286
+ exp_barcodes = [
1287
+ '000035369' , '000035370' , '000035371' ,
1288
+ '000035372' , '000035373'
1289
+ ]
1290
+
1291
+ response = self .client .post (
1292
+ "api/admin/account_barcode_summary?strip_sampleid=False" ,
1293
+ content_type = 'application/json' ,
1294
+ data = input_json ,
1295
+ headers = MOCK_HEADERS
1296
+ )
1297
+ # an empty string project should be unknown
1298
+ self .assertEqual (200 , response .status_code )
1299
+
1300
+ response_obj = json .loads (response .data )
1301
+ self .assertIn ('samples' , response_obj )
1302
+ response_obj = response_obj ['samples' ]
1303
+ self .assertEqual (len (response_obj ), 5 )
1304
+ self .assertEqual ([v ['sampleid' ] for v in response_obj ], exp_barcodes )
1305
+
1255
1306
def test_send_email (self ):
1256
1307
def mock_func (* args , ** kwargs ):
1257
1308
pass
0 commit comments