-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cell_parser.py
34 lines (28 loc) · 1012 Bytes
/
test_cell_parser.py
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
import unittest
import pandas as pd
from excel_parser import parse_cells
class TestParseCells(unittest.TestCase):
def setUp(self):
# Create a sample DataFrame to use in tests
data = {
'A': [1, 2, 3],
'B': [4, 5, 6],
'C': [7, 8, 9]
}
self.sheet = pd.DataFrame(data)
def test_parse_single_cell(self):
cell_map = {'cell1': 'A1'}
result = parse_cells(cell_map, self.sheet)
expected = {'cell1': 1}
self.assertEqual(result, expected)
def test_parse_multiple_cells(self):
cell_map = {'cell1': 'A1', 'cell2': 'B2', 'cell3': 'C3'}
result = parse_cells(cell_map, self.sheet)
expected = {'cell1': 1, 'cell2': 5, 'cell3': 9}
self.assertEqual(result, expected)
def test_parse_nonexistent_cell(self):
cell_map = {'cell1': 'D4'}
with self.assertRaises(IndexError):
parse_cells(cell_map, self.sheet)
if __name__ == '__main__':
unittest.main()