-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathtest_workbook.py
59 lines (47 loc) · 1.59 KB
/
test_workbook.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import unittest
import os.path
from tableaudocumentapi import Datasource, Workbook
TEST_ASSET_DIR = os.path.join(
os.path.dirname(__file__),
'assets'
)
EPHEMERAL_FIELD_FILE = os.path.join(
TEST_ASSET_DIR,
'ephemeral_field.twb'
)
SHAPES_FILE = os.path.join(
TEST_ASSET_DIR,
'shapes_test.twb'
)
DASHBOARDS_FILE = os.path.join(
TEST_ASSET_DIR,
'filtering.twb'
)
class EphemeralFields(unittest.TestCase):
def test_ephemeral_fields_do_not_cause_errors(self):
wb = Workbook(EPHEMERAL_FIELD_FILE)
self.assertIsNotNone(wb)
class Shapes(unittest.TestCase):
def test_shape_exist(self):
wb = Workbook(SHAPES_FILE)
self.assertEqual(wb.shapes, ['Bug Tracking/bug.png',
'Bug Tracking/icon-scheduleitem.png',
'Bug Tracking/light.png',
'Bug Tracking/mail.png',
]
)
def test_shape_count(self):
wb = Workbook(SHAPES_FILE)
self.assertEqual(len(wb.shapes), 4)
class Dashboards(unittest.TestCase):
def test_dashboards_setup(self):
wb = Workbook(DASHBOARDS_FILE)
self.assertIsNotNone(wb)
self.assertEqual(wb.dashboards, ['setTest'])
class Worksheets(unittest.TestCase):
def test_worksheets_setup(self):
wb = Workbook(DASHBOARDS_FILE)
self.assertEqual(len(wb.worksheet_items), 2)
worksheet_names = [ws.name for ws in wb.worksheet_items]
worksheet_names.sort()
self.assertEqual(worksheet_names[0], 'Sheet 1')