Skip to content

Commit 01f232f

Browse files
author
Russell Hay
authored
Add a test to verify #80 (#83)
1 parent b80333d commit 01f232f

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
setup(
77
name='tableaudocumentapi',
88
version='0.3',
9-
author='Tableau Software',
9+
author='Tableau',
1010
author_email='[email protected]',
1111
url='https://github.com/tableau/document-api-python',
1212
packages=['tableaudocumentapi'],

test/assets/unicode.tds

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version='1.0' encoding='utf-8' ?>
2+
<datasource formatted-name='postgres.1of3kl00aoax5d1a1ejma1397430' inline='true' source-platform='mac' version='9.3' xmlns:user='http://www.tableausoftware.com/xml/user'>
3+
<connection authentication='username-password' class='postgres' dbname='TestV1' odbc-native-protocol='yes' port='5432' server='postgres91.test.tsi.lan' username='test'>
4+
<relation name='xy' table='[public].[xy]' type='table' />
5+
<metadata-records>
6+
<metadata-record class='column'>
7+
<remote-name>a</remote-name>
8+
<remote-type>130</remote-type>
9+
<local-name>[a]</local-name>
10+
<parent-name>[xy]</parent-name>
11+
<remote-alias>a</remote-alias>
12+
<ordinal>1</ordinal>
13+
<local-type>string</local-type>
14+
<aggregation>Count</aggregation>
15+
<width>255</width>
16+
<contains-null>true</contains-null>
17+
<attributes>
18+
<attribute datatype='string' name='DebugRemoteType'>&quot;SQL_WVARCHAR&quot;</attribute>
19+
<attribute datatype='string' name='DebugWireType'>&quot;SQL_C_WCHAR&quot;</attribute>
20+
<attribute datatype='string' name='TypeIsVarchar'>&quot;true&quot;</attribute>
21+
</attributes>
22+
</metadata-record>
23+
<metadata-record class='column'>
24+
<remote-name>Today's Date</remote-name>
25+
<remote-type>130</remote-type>
26+
<local-name>[Today&apos;s Date]</local-name>
27+
<parent-name>[xy]</parent-name>
28+
<remote-alias>a</remote-alias>
29+
<ordinal>1</ordinal>
30+
<local-type>string</local-type>
31+
<aggregation>Count</aggregation>
32+
<width>255</width>
33+
<contains-null>true</contains-null>
34+
<attributes>
35+
<attribute datatype='string' name='DebugRemoteType'>&quot;SQL_WVARCHAR&quot;</attribute>
36+
<attribute datatype='string' name='DebugWireType'>&quot;SQL_C_WCHAR&quot;</attribute>
37+
<attribute datatype='string' name='TypeIsVarchar'>&quot;true&quot;</attribute>
38+
</attributes>
39+
</metadata-record>
40+
<metadata-record class='column'>
41+
<remote-name>x</remote-name>
42+
<remote-type>3</remote-type>
43+
<local-name>[x]</local-name>
44+
<parent-name>[xy]</parent-name>
45+
<remote-alias>x</remote-alias>
46+
<ordinal>2</ordinal>
47+
<local-type>integer</local-type>
48+
<aggregation>Sum</aggregation>
49+
<precision>10</precision>
50+
<contains-null>true</contains-null>
51+
<attributes>
52+
<attribute datatype='string' name='DebugRemoteType'>&quot;SQL_INTEGER&quot;</attribute>
53+
<attribute datatype='string' name='DebugWireType'>&quot;SQL_C_SLONG&quot;</attribute>
54+
</attributes>
55+
</metadata-record>
56+
<metadata-record class='column'>
57+
<remote-name>y</remote-name>
58+
<remote-type>3</remote-type>
59+
<local-name>[y]</local-name>
60+
<parent-name>[xy]</parent-name>
61+
<remote-alias>y</remote-alias>
62+
<ordinal>3</ordinal>
63+
<local-type>integer</local-type>
64+
<aggregation>Sum</aggregation>
65+
<precision>10</precision>
66+
<contains-null>true</contains-null>
67+
<attributes>
68+
<attribute datatype='string' name='DebugRemoteType'>&quot;SQL_INTEGER&quot;</attribute>
69+
<attribute datatype='string' name='DebugWireType'>&quot;SQL_C_SLONG&quot;</attribute>
70+
</attributes>
71+
</metadata-record>
72+
</metadata-records>
73+
</connection>
74+
<aliases enabled='yes' />
75+
<column datatype='integer' name='[Number of Records]' role='measure' type='quantitative' user:auto-column='numrec'>
76+
<calculation class='tableau' formula='1' />
77+
</column>
78+
<column caption='A' datatype='string' name='[a]' role='dimension' type='nominal'>
79+
<desc>
80+
<formatted-text>
81+
<run bold='true' fontsize='96'>año</run>
82+
<run fontcolor='#686868'>&#10;Something will go here too, in a muted gray</run>
83+
</formatted-text>
84+
</desc>
85+
</column>
86+
<column caption='Today&apos;s Date' datatype='string' name='[Today&apos;s Date]' role='dimension' type='nominal' />
87+
<column caption='X' datatype='integer' name='[x]' role='measure' type='ordinal' />
88+
<column caption='Y' datatype='integer' name='[y]' role='measure' type='quantitative' />
89+
<layout dim-ordering='alphabetic' dim-percentage='0.5' measure-ordering='alphabetic' measure-percentage='0.5' show-structure='true' />
90+
<semantic-values>
91+
<semantic-value key='[Country].[Name]' value='&quot;United States&quot;' />
92+
</semantic-values>
93+
</datasource>

test/test_field.py

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
TEST_ASSET_DIR,
1313
'datasource_test.tds'
1414
)
15+
TEST_UNICODE_FILE = os.path.join(
16+
TEST_ASSET_DIR,
17+
'unicode.tds'
18+
)
1519

1620

1721
class FieldsUnitTest(unittest.TestCase):
@@ -27,3 +31,9 @@ def find(self, *args, **kwargs):
2731

2832
def test_find_metadata_record_returns_none(self):
2933
self.assertIsNone(_find_metadata_record(self.MockXmlWithNoFind(), 'foo'))
34+
35+
36+
class FieldsHandleUnicode(unittest.TestCase):
37+
def test_description_unicode(self):
38+
ds = Datasource.from_file(TEST_UNICODE_FILE)
39+
self.assertIsNotNone(ds.fields['A'].description)

0 commit comments

Comments
 (0)