Skip to content

Commit d987b41

Browse files
committed
Add tests for str_to_array
1 parent 054e4a6 commit d987b41

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/test_file_peeking.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ def test_encoding(build_test_samples,tmp_path, capsys):
7575
assert encoded_result == expected_result
7676

7777
# Produce servicex.deliver() like dict
78+
# i.e {"Sample Name":"Path"}
7879
tree_data= {"branch" : query_output}
7980
with uproot.create(tmp_path / "encoded.root") as file:
8081
file["servicex"]= tree_data
8182
assert os.path.exists(tmp_path / "encoded.root"), f"servicex-like test file not found."
8283
deliver_dict={"test_file":[str(tmp_path / "encoded.root")]}
8384

8485

85-
## Test decoding structure formating
86+
## Test str formating on the deliver-like dict
8687
# save_to_txt
8788
file_peeking.print_structure_from_str(deliver_dict,save_to_txt=True)
8889
out_txt="samples_structure.txt"
@@ -153,3 +154,15 @@ def test_spec_builder():
153154
wrong_did=1234
154155
with pytest.raises(ValueError, match=re.escape(f"Unsupported dataset input type: {type(wrong_did)}.\nInput must be dict ('sample_name':'dataset_id'), str or list of str")):
155156
file_peeking.build_deliver_spec(wrong_did)
157+
158+
def test_decoding_to_array(build_test_samples,array_out=True):
159+
path=build_test_samples
160+
query_output=file_peeking.run_query(path)
161+
encoded_result=query_output[0]
162+
163+
result=file_peeking.str_to_array(encoded_result)
164+
165+
#Test type
166+
assert isinstance(result, ak.Array), "str_to_array does not return an awkward array"
167+
expected_type_str="1 * {background: {branch1: var * float64, branch2: var * float64}, signal: {branch1: var * float64}}"
168+
assert str(result.type) == expected_type_str

0 commit comments

Comments
 (0)