11from tempfile import NamedTemporaryFile
2+ import uuid
3+ import time
24
35import pytest
46import requests
@@ -11,6 +13,36 @@ def test_get_data_row(datarow, client):
1113 assert client .get_data_row (datarow .uid )
1214
1315
16+ def test_lookup_data_rows (client , dataset ):
17+ uid = str (uuid .uuid4 ())
18+ # 1 external id : 1 uid
19+ dr = dataset .create_data_row (row_data = "123" , external_id = uid )
20+ lookup = client .get_data_row_ids_for_external_ids ([uid ])
21+ assert len (lookup ) == 1
22+ assert lookup [uid ][0 ] == dr .uid
23+ # 2 external ids : 1 uid
24+ uid2 = str (uuid .uuid4 ())
25+ dr2 = dataset .create_data_row (row_data = "123" , external_id = uid2 )
26+ lookup = client .get_data_row_ids_for_external_ids ([uid , uid2 ])
27+ assert len (lookup ) == 2
28+ assert all ([len (x ) == 1 for x in lookup .values ()])
29+ assert lookup [uid ][0 ] == dr .uid
30+ assert lookup [uid2 ][0 ] == dr2 .uid
31+ #1 external id : 2 uid
32+ dr3 = dataset .create_data_row (row_data = "123" , external_id = uid2 )
33+ lookup = client .get_data_row_ids_for_external_ids ([uid2 ])
34+ assert len (lookup ) == 1
35+ assert len (lookup [uid2 ]) == 2
36+ assert lookup [uid2 ][0 ] == dr2 .uid
37+ assert lookup [uid2 ][1 ] == dr3 .uid
38+ # Empty args
39+ lookup = client .get_data_row_ids_for_external_ids ([])
40+ assert len (lookup ) == 0
41+ # Non matching
42+ lookup = client .get_data_row_ids_for_external_ids ([str (uuid .uuid4 ())])
43+ assert len (lookup ) == 0
44+
45+
1446def test_data_row_bulk_creation (dataset , rand_gen , image_url ):
1547 client = dataset .client
1648 assert len (list (dataset .data_rows ())) == 0
0 commit comments