forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_workbook_util.py
More file actions
31 lines (23 loc) · 1.05 KB
/
test_workbook_util.py
File metadata and controls
31 lines (23 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import base64
from galaxy.model.dataset_collections.workbook_util import (
index_to_excel_column,
load_workbook_from_base64,
)
from galaxy.util.resources import resource_path
def test_index_to_excel_column():
assert index_to_excel_column(0) == "A"
assert index_to_excel_column(25) == "Z"
assert index_to_excel_column(26) == "AA"
assert index_to_excel_column(700) == "ZY"
assert index_to_excel_column(701) == "ZZ"
assert index_to_excel_column(702) == "AAA"
def test_load_workbook_from_base64():
workbook_base64 = resource_path_to_base64("filled_in_workbook_1.xlsx")
workbook = load_workbook_from_base64(workbook_base64)
assert workbook is not None
workbook_base64 = resource_path_to_base64("filled_in_workbook_1.tsv")
workbook = load_workbook_from_base64(workbook_base64)
assert workbook is not None
def resource_path_to_base64(resource_name: str) -> str:
resource_bytes = resource_path("galaxy.model.unittest_utils", resource_name).read_bytes()
return base64.b64encode(resource_bytes).decode("utf-8")