-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertcsv_test.py
More file actions
51 lines (35 loc) · 1.27 KB
/
convertcsv_test.py
File metadata and controls
51 lines (35 loc) · 1.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Module providing a function to exit early"""
import sys
import shutil
from Home import convert_csv
test_filename_list = [
"mock_data/mock_proteomics_data.csv",
"mock_data/mock_proteomics_data.txt",
]
test_file_list = []
for filename in test_filename_list:
shutil.copyfile(filename, filename.split("/")[-1])
file = open(filename.split("/")[-1], "r", encoding="utf-8")
test_file_list.append(file)
print("::debug::Testing convert_csv")
test_filename_converted_list = convert_csv(test_file_list)
print("::notice::Success convert_csv")
for file in test_file_list:
file.close()
original_file = open(test_filename_list[0], "r", encoding="utf-8")
original_file_content = original_file.read()
original_file.close()
print("::debug::Checking convert_csv output was correct")
for filename in test_filename_converted_list:
try:
file = open(filename, "r", encoding="utf-8")
except Exception as e:
print(f"::error::Error opening file: {filename}, error is {e}")
sys.exit(1)
file_content = file.read()
if file_content != original_file_content:
print("::error::Success convert_csv output was incorrect")
sys.exit(1)
file.close()
print("::notice::Success convert_csv output was correct")
sys.exit(0)