forked from tableau/document-api-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_field.py
More file actions
39 lines (30 loc) · 1 KB
/
test_field.py
File metadata and controls
39 lines (30 loc) · 1 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
import unittest
import os.path
from tableaudocumentapi import Datasource, Field
from tableaudocumentapi.field import _find_metadata_record
TEST_ASSET_DIR = os.path.join(
os.path.dirname(__file__),
'assets'
)
TEST_TDS_FILE = os.path.join(
TEST_ASSET_DIR,
'datasource_test.tds'
)
TEST_UNICODE_FILE = os.path.join(
TEST_ASSET_DIR,
'unicode.tds'
)
class FieldsUnitTest(unittest.TestCase):
def test_field_throws_if_no_data_passed_in(self):
with self.assertRaises(AttributeError):
Field()
class FindMetaDataRecordEdgeTest(unittest.TestCase):
class MockXmlWithNoFind(object):
def find(self, *args, **kwargs):
return None
def test_find_metadata_record_returns_none(self):
self.assertIsNone(_find_metadata_record(self.MockXmlWithNoFind(), 'foo'))
class FieldsHandleUnicode(unittest.TestCase):
def test_description_unicode(self):
ds = Datasource.from_file(TEST_UNICODE_FILE)
self.assertIsNotNone(ds.fields['A'].description)