diff --git a/test/_utils.py b/test/_utils.py index b4ee93bc3..c5520bf2a 100644 --- a/test/_utils.py +++ b/test/_utils.py @@ -6,12 +6,17 @@ TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") -def asset(filename): +# should rename this because json files are also in the responses directory +def xml_asset_path(filename): return os.path.join(TEST_ASSET_DIR, filename) +def data_asset_path(filename): + return os.path.join(TEST_ASSET_DIR, "Data", filename) + + def read_xml_asset(filename): - with open(asset(filename), "rb") as f: + with open(xml_asset_path(filename), "rb") as f: return f.read().decode("utf-8") diff --git a/test/assets/RESTAPISample Image.png b/test/assets/Data/RESTAPISample Image.png similarity index 100% rename from test/assets/RESTAPISample Image.png rename to test/assets/Data/RESTAPISample Image.png diff --git a/test/assets/RESTAPISample.twb b/test/assets/Data/RESTAPISample.twb similarity index 98% rename from test/assets/RESTAPISample.twb rename to test/assets/Data/RESTAPISample.twb index 616bed91e..4473b5f60 100644 --- a/test/assets/RESTAPISample.twb +++ b/test/assets/Data/RESTAPISample.twb @@ -1,3573 +1,3573 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Country / Region - 129 - [Country / Region] - [Extract] - Country / Region - 0 - DATA$ - string - Count - 209 - 1 - 1073741823 - false - - - "Afghanistan" - "Zimbabwe" - - - "en_US_CI" - true - "heap" - true - 4294967292 - 7 - "asc" - 2 - "str" - - - - Date - 135 - [Date] - [Extract] - Date - 1 - DATA$ - datetime - Year - 11 - false - - #2000-07-01 00:00:00# - #2010-07-01 00:00:00# - - - true - "array" - true - "asc" - 8 - 0 - "asc" - 1 - "datetime" - - - - F: Deposit interest rate (%) - 4 - [F: Deposit interest rate (%)] - [Extract] - F: Deposit interest rate (%) - 2 - DATA$ - real - Sum - 50 - true - - 0.0 - 203.0 - - - true - "array" - true - 4 - 5 - "asc" - 1 - "float" - - - - F: GDP (curr $) - 5 - [F: GDP (curr $)] - [Extract] - F: GDP (curr $) - 3 - DATA$ - real - Sum - 2120 - true - - 63810762.0 - 14447100000000.0 - - - 8 - 10 - "asc" - "double" - - - - F: GDP per capita (curr $) - 4 - [F: GDP per capita (curr $)] - [Extract] - F: GDP per capita (curr $) - 4 - DATA$ - real - Sum - 1877 - true - - 87.0 - 186243.0 - - - 4 - 9 - "asc" - "float" - - - - F: Lending interest rate (%) - 4 - [F: Lending interest rate (%)] - [Extract] - F: Lending interest rate (%) - 5 - DATA$ - real - Sum - 72 - true - - 1.0 - 496.0 - - - true - "array" - true - 4 - 6 - "asc" - 1 - "float" - - - - H: Health exp (% GDP) - 4 - [H: Health exp (% GDP)] - [Extract] - H: Health exp (% GDP) - 6 - DATA$ - real - Sum - 22 - true - - 0.0 - 20.0 - - - true - "array" - true - 4 - 3 - "asc" - 1 - "float" - - - - H: Health exp/cap (curr $) - 4 - [H: Health exp/cap (curr $)] - [Extract] - H: Health exp/cap (curr $) - 7 - DATA$ - real - Sum - 936 - true - - 3.0 - 8362.0 - - - true - "array" - true - 4 - 8 - "asc" - 2 - "float" - - - - H: Life exp (years) - 4 - [H: Life exp (years)] - [Extract] - H: Life exp (years) - 8 - DATA$ - real - Sum - 45 - true - - 40.0 - 83.0 - - - true - "array" - true - 4 - 4 - "asc" - 1 - "float" - - - - Number of Records - 16 - [Number of Records] - [Extract] - Number of Records - 9 - integer - Sum - 1 - false - - 1 - 1 - - - "asc" - 1 - "sint8" - - - - P: Population (count) - 5 - [P: Population (count)] - [Extract] - P: Population (count) - 10 - DATA$ - real - Sum - 2295 - false - - 18873.0 - 1337825000.0 - - - 8 - 11 - "asc" - "double" - - - - Region - 129 - [Region] - [Extract] - Region - 11 - DATA$ - string - Count - 6 - 1 - 1073741823 - false - - - "Africa" - "The Americas" - - - "en_US_CI" - true - "heap" - true - 4294967292 - 1 - "asc" - 1 - "str" - - - - Subregion - 129 - [Subregion] - [Extract] - Subregion - 12 - DATA$ - string - Count - 12 - 1 - 1073741823 - true - - - "Caribbean" - "Western Africa" - - - "en_US_CI" - true - "heap" - true - 4294967292 - 2 - "asc" - 1 - "str" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gross Domestic Product - in current US Dollars - - - - - - - Gross Domestic Product - per capita - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Region] - [Subregion] - [Country / Region] - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Europe" - "Middle East" - "The Americas" - "Oceania" - "Asia" - "Africa" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <formatted-text> - <run fontsize='12'>Country ranks by GDP, GDP per Capita, Population, and Life Expectancy</run> - </formatted-text> - - - - - - - - - - - - - - Gross Domestic Product - in current US Dollars - - - - - - - Gross Domestic Product - per capita - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "[World Indicators new].[sum:F: GDP (curr $):qk]" - "[World Indicators new].[rank:sum:F: GDP (curr $):qk]" - "[World Indicators new].[sum:F: GDP per capita (curr $):qk]" - "[World Indicators new].[rank:sum:F: GDP per capita (curr $):qk]" - "[World Indicators new].[sum:P: Population (count):qk]" - "[World Indicators new].[rank:sum:P: Population (count):qk]" - "[World Indicators new].[avg:H: Life exp (years):qk]" - "[World Indicators new].[rank:avg:H: Life exp (years) (copy):qk]" - - - - - - - - - [World Indicators new].[:Measure Names] - [World Indicators new].[yr:Date:ok] - [World Indicators new].[none:F: GDP (curr $):qk] - - - - - - - - - - - - - - - - <[World Indicators new].[none:Country / Region:nk]> - Æ - <[World Indicators new].[:Measure Names]>: - <[World Indicators new].[Multiple Values]> - - - - - - [World Indicators new].[none:Country / Region:nk] - [World Indicators new].[:Measure Names] -
-
- - - - <formatted-text> - <run fontsize='11'><</run> - <run fontsize='11'>[World Indicators new].[yr:Date:ok]</run> - <run fontsize='11'>></run> - <run fontsize='11'> GDP per capita by country</run> - </formatted-text> - - - - - - - - - - - - - - - - - - - Gross Domestic Product - per capita - - - - - - - - - - - - - - - - - - - - - - [World Indicators new].[yr:Date:ok] - [World Indicators new].[none:Region:nk] - - - - - - - - - - - - - - - - - - - Country: - <[World Indicators new].[none:Country / Region:nk]> - Region: - <[World Indicators new].[none:Region:nk]> - GDP per capita (curr $): - <[World Indicators new].[avg:F: GDP per capita (curr $):qk]> - % of world average: - <[World Indicators new].[usr:Calculation1:qk]> - - - - - - [World Indicators new].[none:Country / Region:nk] - [World Indicators new].[avg:F: GDP per capita (curr $):qk] -
-
- - - - <formatted-text> - <run fontsize='12'>GDP per capita by region </run> - <run>Click on a point to filter the map to a specific year.</run> - </formatted-text> - - - - - - - - - - - - - - - - - Gross Domestic Product - in current US Dollars - - - - - - - - - - - - - - - - - - [World Indicators new].[Action (Country Name)] - [World Indicators new].[Action (Region)] - - - - - - - - - - - - - - - - - <[World Indicators new].[none:Region:nk]> - Year: - <[World Indicators new].[yr:Date:ok]> - Average GDP (curr $): - <[World Indicators new].[avg:F: GDP (curr $):qk]> - GDP per capita (weighted): - <[World Indicators new].[usr:Calculation_1590906174513693:qk]> - - - - - - [World Indicators new].[usr:Calculation_1590906174513693:qk] - [World Indicators new].[yr:Date:ok] -
-
- - - - <formatted-text> - <run fontsize='12'>GDP per capita by country </run> - <run>Currently filtered to </run> - <run fontcolor='#4f6e8d'><[World Indicators new].[yr:Date:ok]></run> - </formatted-text> - - - - - - - - - - - - - - - - - - - - - - Gross Domestic Product - per capita - - - - - - - - - - - - - - - - - - - - - - - - - - - - 199.0 - 104512.0 - - - - - - - - "The Americas" - "Europe" - %null% - "Oceania" - "Africa" - "Middle East" - "Asia" - %all% - - - - [World Indicators new].[avg:F: GDP per capita (curr $):qk] - [World Indicators new].[none:Region:nk] - [World Indicators new].[Action (YEAR(Date (year)))] - - - - - - - - - - - - - - - - - - - - - <[World Indicators new].[none:Country / Region:nk]> - Æ - Region: - <[World Indicators new].[none:Region:nk]> - Subregion: - <[World Indicators new].[none:Subregion:nk]> - GDP per capita (curr $): - <[World Indicators new].[avg:F: GDP per capita (curr $):qk]> - GDP % of Subregion average: - <[World Indicators new].[usr:Calculation1:qk:5]> - GDP % of World average: - <[World Indicators new].[usr:Calculation1:qk:1]> - - - - - - [World Indicators new].[Latitude (generated)] - [World Indicators new].[Longitude (generated)] -
-
- - - - <formatted-text> - <run fontsize='12'><Sheet Name>, <Page Name></run> - <run>Æ </run> - <run fontcolor='#898989' fontsize='10'>Click the forward button on year to watch the change over time Hover over mark to see the history of that country</run> - </formatted-text> - - - - - - - - - - - - - - - - - - - - - - - [World Indicators new].[avg:H: Health exp/cap (curr $):qk] - [World Indicators new].[avg:H: Life exp (years):qk] - - - - - - - - - - - - - - - - - <[World Indicators new].[none:Country / Region:nk]> - Æ - Region: - <[World Indicators new].[none:Region:nk]> - Year: - <[World Indicators new].[yr:Date:ok]> - Health exp/cap (curr $): - <[World Indicators new].[avg:H: Health exp/cap (curr $):qk]> - Life Expectancy: - <[World Indicators new].[avg:H: Life exp (years):qk]> - - - - - - [World Indicators new].[avg:H: Life exp (years):qk] - [World Indicators new].[avg:H: Health exp/cap (curr $):qk] - - [World Indicators new].[yr:Date:ok] - - -
-
- - - - <formatted-text> - <run fontsize='12'>Lending and deposit interest rates, GDP per capita and % of world GDP sorted by GDP per Capita for region and subregion, </run> - <run fontsize='12'><</run> - <run fontsize='12'>[World Indicators new].[yr:Date:ok]</run> - <run fontsize='12'>></run> - </formatted-text> - - - - - - - - - - - - - - - - - - - - Gross Domestic Product - in current US Dollars - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "[World Indicators new].[avg:F: Lending interest rate (\%):qk]" - "[World Indicators new].[avg:F: Deposit interest rate (\%):qk]" - "[World Indicators new].[usr:Calculation_8570907072742130:qk]" - "[World Indicators new].[usr:Calculation_1590906174513693:qk]" - "[World Indicators new].[pcto:sum:F: GDP (curr $):qk]" - - - - - - - - - [World Indicators new].[:Measure Names] - [World Indicators new].[yr:Date:ok] - - - - - - - - - - - - - - - - - ([World Indicators new].[none:Region:nk] / [World Indicators new].[none:Subregion:nk]) - [World Indicators new].[:Measure Names] -
-
- - - - <formatted-text> - <run><[World Indicators new].[yr:Date:ok]> Country <Sheet Name></run> - </formatted-text> - - - - - - - - - - - - - - Gross Domestic Product - in current US Dollars - - - - - - - - - - - - - - - - - - - - [World Indicators new].[yr:Date:ok] - [World Indicators new].[sum:F: GDP (curr $):qk] - - - - - - - - - - - - - - - - - - - - <[World Indicators new].[none:Country / Region:nk]> - Æ - Region: - <[World Indicators new].[none:Region:nk]> - % of World GDP: - <[World Indicators new].[pcto:sum:F: GDP (curr $):qk:1]> - GDP (US $'s): - <[World Indicators new].[sum:F: GDP (curr $):qk]> - - - - - <[World Indicators new].[none:Country / Region:nk]> - Æ - <[World Indicators new].[pcto:sum:F: GDP (curr $):qk:1]> <[World Indicators new].[sum:F: GDP (curr $):qk]> - - - - - - - -
-
-
- - - - - <formatted-text> - <run fontalignment='0'>GDP per Capita</run> - </formatted-text> - - - + + + + + + + "Europe" + "Middle East" + "The Americas" + "Oceania" + "Asia" + "Africa" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <formatted-text> + <run fontsize='12'>Country ranks by GDP, GDP per Capita, Population, and Life Expectancy</run> + </formatted-text> + + + + + + + + + + + + + + Gross Domestic Product + in current US Dollars + + + + + + + Gross Domestic Product + per capita + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "[World Indicators new].[sum:F: GDP (curr $):qk]" + "[World Indicators new].[rank:sum:F: GDP (curr $):qk]" + "[World Indicators new].[sum:F: GDP per capita (curr $):qk]" + "[World Indicators new].[rank:sum:F: GDP per capita (curr $):qk]" + "[World Indicators new].[sum:P: Population (count):qk]" + "[World Indicators new].[rank:sum:P: Population (count):qk]" + "[World Indicators new].[avg:H: Life exp (years):qk]" + "[World Indicators new].[rank:avg:H: Life exp (years) (copy):qk]" + + + + + + + + + [World Indicators new].[:Measure Names] + [World Indicators new].[yr:Date:ok] + [World Indicators new].[none:F: GDP (curr $):qk] + + + + + + + + + + + + + + + + <[World Indicators new].[none:Country / Region:nk]> + Æ + <[World Indicators new].[:Measure Names]>: + <[World Indicators new].[Multiple Values]> + + + + + + [World Indicators new].[none:Country / Region:nk] + [World Indicators new].[:Measure Names] +
+
+ + + + <formatted-text> + <run fontsize='11'><</run> + <run fontsize='11'>[World Indicators new].[yr:Date:ok]</run> + <run fontsize='11'>></run> + <run fontsize='11'> GDP per capita by country</run> + </formatted-text> + + + + + + + + + + + + + + + + + + + Gross Domestic Product + per capita + + + + + + + + + + + + + + + + + + + + + + [World Indicators new].[yr:Date:ok] + [World Indicators new].[none:Region:nk] + + + + + + + + + + + + + + + + + + + Country: + <[World Indicators new].[none:Country / Region:nk]> + Region: + <[World Indicators new].[none:Region:nk]> + GDP per capita (curr $): + <[World Indicators new].[avg:F: GDP per capita (curr $):qk]> + % of world average: + <[World Indicators new].[usr:Calculation1:qk]> + + + + + + [World Indicators new].[none:Country / Region:nk] + [World Indicators new].[avg:F: GDP per capita (curr $):qk] +
+
+ + + + <formatted-text> + <run fontsize='12'>GDP per capita by region </run> + <run>Click on a point to filter the map to a specific year.</run> + </formatted-text> + + + + + + + + + + + + + + + + + Gross Domestic Product + in current US Dollars + + + + + + + + + + + + + + + + + + [World Indicators new].[Action (Country Name)] + [World Indicators new].[Action (Region)] + + + + + + + + + + + + + + + + + <[World Indicators new].[none:Region:nk]> + Year: + <[World Indicators new].[yr:Date:ok]> + Average GDP (curr $): + <[World Indicators new].[avg:F: GDP (curr $):qk]> + GDP per capita (weighted): + <[World Indicators new].[usr:Calculation_1590906174513693:qk]> + + + + + + [World Indicators new].[usr:Calculation_1590906174513693:qk] + [World Indicators new].[yr:Date:ok] +
+
+ + + + <formatted-text> + <run fontsize='12'>GDP per capita by country </run> + <run>Currently filtered to </run> + <run fontcolor='#4f6e8d'><[World Indicators new].[yr:Date:ok]></run> + </formatted-text> + + + + + + + + + + + + + + + + + + + + + + Gross Domestic Product + per capita + + + + + + + + + + + + + + + + + + + + + + + + + + + + 199.0 + 104512.0 + + + + + + + + "The Americas" + "Europe" + %null% + "Oceania" + "Africa" + "Middle East" + "Asia" + %all% + + + + [World Indicators new].[avg:F: GDP per capita (curr $):qk] + [World Indicators new].[none:Region:nk] + [World Indicators new].[Action (YEAR(Date (year)))] + + + + + + + + + + + + + + + + + + + + + <[World Indicators new].[none:Country / Region:nk]> + Æ + Region: + <[World Indicators new].[none:Region:nk]> + Subregion: + <[World Indicators new].[none:Subregion:nk]> + GDP per capita (curr $): + <[World Indicators new].[avg:F: GDP per capita (curr $):qk]> + GDP % of Subregion average: + <[World Indicators new].[usr:Calculation1:qk:5]> + GDP % of World average: + <[World Indicators new].[usr:Calculation1:qk:1]> + + + + + + [World Indicators new].[Latitude (generated)] + [World Indicators new].[Longitude (generated)] +
+
+ + + + <formatted-text> + <run fontsize='12'><Sheet Name>, <Page Name></run> + <run>Æ </run> + <run fontcolor='#898989' fontsize='10'>Click the forward button on year to watch the change over time Hover over mark to see the history of that country</run> + </formatted-text> + + + + + + + + + + + + + + + + + + + + + + + [World Indicators new].[avg:H: Health exp/cap (curr $):qk] + [World Indicators new].[avg:H: Life exp (years):qk] + + + + + + + + + + + + + + + + + <[World Indicators new].[none:Country / Region:nk]> + Æ + Region: + <[World Indicators new].[none:Region:nk]> + Year: + <[World Indicators new].[yr:Date:ok]> + Health exp/cap (curr $): + <[World Indicators new].[avg:H: Health exp/cap (curr $):qk]> + Life Expectancy: + <[World Indicators new].[avg:H: Life exp (years):qk]> + + + + + + [World Indicators new].[avg:H: Life exp (years):qk] + [World Indicators new].[avg:H: Health exp/cap (curr $):qk] + + [World Indicators new].[yr:Date:ok] + + +
+
+ + + + <formatted-text> + <run fontsize='12'>Lending and deposit interest rates, GDP per capita and % of world GDP sorted by GDP per Capita for region and subregion, </run> + <run fontsize='12'><</run> + <run fontsize='12'>[World Indicators new].[yr:Date:ok]</run> + <run fontsize='12'>></run> + </formatted-text> + + + + + + + + + + + + + + + + + + + + Gross Domestic Product + in current US Dollars + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "[World Indicators new].[avg:F: Lending interest rate (\%):qk]" + "[World Indicators new].[avg:F: Deposit interest rate (\%):qk]" + "[World Indicators new].[usr:Calculation_8570907072742130:qk]" + "[World Indicators new].[usr:Calculation_1590906174513693:qk]" + "[World Indicators new].[pcto:sum:F: GDP (curr $):qk]" + + + + + + + + + [World Indicators new].[:Measure Names] + [World Indicators new].[yr:Date:ok] + + + + + + + + + + + + + + + + + ([World Indicators new].[none:Region:nk] / [World Indicators new].[none:Subregion:nk]) + [World Indicators new].[:Measure Names] +
+
+ + + + <formatted-text> + <run><[World Indicators new].[yr:Date:ok]> Country <Sheet Name></run> + </formatted-text> + + + + + + + + + + + + + + Gross Domestic Product + in current US Dollars + + + + + + + + + + + + + + + + + + + + [World Indicators new].[yr:Date:ok] + [World Indicators new].[sum:F: GDP (curr $):qk] + + + + + + + + + + + + + + + + + + + + <[World Indicators new].[none:Country / Region:nk]> + Æ + Region: + <[World Indicators new].[none:Region:nk]> + % of World GDP: + <[World Indicators new].[pcto:sum:F: GDP (curr $):qk:1]> + GDP (US $'s): + <[World Indicators new].[sum:F: GDP (curr $):qk]> + + + + + <[World Indicators new].[none:Country / Region:nk]> + Æ + <[World Indicators new].[pcto:sum:F: GDP (curr $):qk:1]> <[World Indicators new].[sum:F: GDP (curr $):qk]> + + + + + + + +
+
+
+ + + + + <formatted-text> + <run fontalignment='0'>GDP per Capita</run> + </formatted-text> + + + - - - - - - - "Europe" - "Middle East" - "The Americas" - "Oceania" - "Asia" - "Africa" - - - - <_.fcp.ObjectModelEncapsulateLegacy.true...object-graph> - - - - - - - - - + + + + + + <_.fcp.ObjectModelEncapsulateLegacy.true...ObjectModelEncapsulateLegacy /> + <_.fcp.ObjectModelTableType.true...ObjectModelTableType /> + <_.fcp.SchemaViewerObjectModel.true...SchemaViewerObjectModel /> + + + + + + + + + + + + + <_.fcp.ObjectModelEncapsulateLegacy.false...relation connection='World Indicators newleaf' name='Extract' table='[Extract].[Extract]' type='table' /> + <_.fcp.ObjectModelEncapsulateLegacy.true...relation connection='World Indicators newleaf' name='Extract' table='[Extract].[Extract]' type='table' /> + + + Country / Region + 129 + [Country / Region] + [Extract] + Country / Region + 0 + DATA$ + string + Count + 209 + false + + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + Date + 135 + [Date] + [Extract] + Date + 1 + DATA$ + datetime + Year + 11 + false + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + F: Deposit interest rate (%) + 5 + [F: Deposit interest rate (%)] + [Extract] + F: Deposit interest rate (%) + 2 + DATA$ + real + Sum + 50 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + F: GDP (curr $) + 5 + [F: GDP (curr $)] + [Extract] + F: GDP (curr $) + 3 + DATA$ + real + Sum + 2120 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + F: GDP per capita (curr $) + 5 + [F: GDP per capita (curr $)] + [Extract] + F: GDP per capita (curr $) + 4 + DATA$ + real + Sum + 1877 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + F: Lending interest rate (%) + 5 + [F: Lending interest rate (%)] + [Extract] + F: Lending interest rate (%) + 5 + DATA$ + real + Sum + 72 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + H: Health exp (% GDP) + 5 + [H: Health exp (% GDP)] + [Extract] + H: Health exp (% GDP) + 6 + DATA$ + real + Sum + 22 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + H: Health exp/cap (curr $) + 5 + [H: Health exp/cap (curr $)] + [Extract] + H: Health exp/cap (curr $) + 7 + DATA$ + real + Sum + 936 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + H: Life exp (years) + 5 + [H: Life exp (years)] + [Extract] + H: Life exp (years) + 8 + DATA$ + real + Sum + 45 + true + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + Number of Records + 2 + [Number of Records] + [Extract] + Number of Records + 9 + integer + Sum + 1 + false + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + P: Population (count) + 5 + [P: Population (count)] + [Extract] + P: Population (count) + 10 + DATA$ + real + Sum + 2295 + false + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + Region + 129 + [Region] + [Extract] + Region + 11 + DATA$ + string + Count + 6 + false + + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + Subregion + 129 + [Subregion] + [Extract] + Subregion + 12 + DATA$ + string + Count + 12 + true + + <_.fcp.ObjectModelEncapsulateLegacy.true...object-id>[Migrated Data] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gross Domestic Product + in current US Dollars + + + + + + + Gross Domestic Product + per capita + + + + + + + + + + + + + + + + + + <_.fcp.ObjectModelTableType.true...column caption='Migrated Data' datatype='table' name='[__tableau_internal_object_id__].[Migrated Data]' role='measure' type='quantitative' /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Region] + [Subregion] + [Country / Region] + + + <_.fcp.SchemaViewerObjectModel.false...folder name='Financial' role='measures'> + + + + + + + + + <_.fcp.SchemaViewerObjectModel.false...folder name='Health' role='measures'> + + + + + <_.fcp.SchemaViewerObjectModel.false...folder name='Population' role='measures'> + + + <_.fcp.SchemaViewerObjectModel.true...folders-common> + + + + + + + + + + + + + + + + + + + + + + + + + + + "Europe" + "Middle East" + "The Americas" + "Oceania" + "Asia" + "Africa" + + + + <_.fcp.ObjectModelEncapsulateLegacy.true...object-graph> + + + + + + + + + diff --git a/test/assets/World Indicators.tdsx b/test/assets/Data/World Indicators.tdsx similarity index 100% rename from test/assets/World Indicators.tdsx rename to test/assets/Data/World Indicators.tdsx diff --git a/test/assets/Data/populate_csv.csv b/test/assets/Data/populate_csv.csv new file mode 100644 index 000000000..bab9f1506 --- /dev/null +++ b/test/assets/Data/populate_csv.csv @@ -0,0 +1,25 @@ +Measure Names,Region,Profit Ratio,Sales per Customer,Distinct count of Customer Name,Measure Values,Profit,Quantity,Sales +Count of Customers,South,14.4%,$711.83,438,438,"$45,047","5,004","$311,784" +Sales,South,14.4%,$711.83,438,"311,783.644","$45,047","5,004","$311,784" +Quantity,South,14.4%,$711.83,438,"5,004","$45,047","5,004","$311,784" +Sales per Customer,South,14.4%,$711.83,438,711.834803653,"$45,047","5,004","$311,784" +Profit,South,14.4%,$711.83,438,"45,047.2231","$45,047","5,004","$311,784" +Profit Ratio,South,14.4%,$711.83,438,0.144482316,"$45,047","5,004","$311,784" +Count of Customers,Central,9.3%,$746.66,566,566,"$39,176","6,990","$422,611" +Sales,Central,9.3%,$746.66,566,"422,610.558800001","$39,176","6,990","$422,611" +Quantity,Central,9.3%,$746.66,566,"6,990","$39,176","6,990","$422,611" +Sales per Customer,Central,9.3%,$746.66,566,746.661764664,"$39,176","6,990","$422,611" +Profit,Central,9.3%,$746.66,566,"39,176.1836","$39,176","6,990","$422,611" +Profit Ratio,Central,9.3%,$746.66,566,0.092700437,"$39,176","6,990","$422,611" +Count of Customers,East,12.7%,$825.74,624,624,"$65,476","8,255","$515,262" +Sales,East,12.7%,$825.74,624,"515,261.598000001","$65,476","8,255","$515,262" +Quantity,East,12.7%,$825.74,624,"8,255","$65,476","8,255","$515,262" +Sales per Customer,East,12.7%,$825.74,624,825.739740385,"$65,476","8,255","$515,262" +Profit,East,12.7%,$825.74,624,"65,475.852700000","$65,476","8,255","$515,262" +Profit Ratio,East,12.7%,$825.74,624,0.127073030,"$65,476","8,255","$515,262" +Count of Customers,West,14.4%,$906.73,630,630,"$82,264","9,544","$571,239" +Sales,West,14.4%,$906.73,630,"571,239.036500001","$82,264","9,544","$571,239" +Quantity,West,14.4%,$906.73,630,"9,544","$82,264","9,544","$571,239" +Sales per Customer,West,14.4%,$906.73,630,906.728629365,"$82,264","9,544","$571,239" +Profit,West,14.4%,$906.73,630,"82,263.903800000","$82,264","9,544","$571,239" +Profit Ratio,West,14.4%,$906.73,630,0.144009598,"$82,264","9,544","$571,239" diff --git a/test/assets/Data/populate_excel.xlsx b/test/assets/Data/populate_excel.xlsx new file mode 100644 index 000000000..3cf6115c7 Binary files /dev/null and b/test/assets/Data/populate_excel.xlsx differ diff --git a/test/assets/Data/populate_pdf.pdf b/test/assets/Data/populate_pdf.pdf new file mode 100644 index 000000000..4d3319442 Binary files /dev/null and b/test/assets/Data/populate_pdf.pdf differ diff --git a/test/assets/Data/populate_powerpoint.pptx b/test/assets/Data/populate_powerpoint.pptx new file mode 100644 index 000000000..dbf979c06 Binary files /dev/null and b/test/assets/Data/populate_powerpoint.pptx differ diff --git a/test/test_auth.py b/test/test_auth.py index 09e3e251d..1051ab63b 100644 --- a/test/test_auth.py +++ b/test/test_auth.py @@ -1,15 +1,14 @@ -import os.path import unittest import requests_mock import tableauserverclient as TSC -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") +from test._utils import xml_asset_path -SIGN_IN_XML = os.path.join(TEST_ASSET_DIR, "auth_sign_in.xml") -SIGN_IN_IMPERSONATE_XML = os.path.join(TEST_ASSET_DIR, "auth_sign_in_impersonate.xml") -SIGN_IN_ERROR_XML = os.path.join(TEST_ASSET_DIR, "auth_sign_in_error.xml") +SIGN_IN_XML = xml_asset_path("auth_sign_in.xml") +SIGN_IN_IMPERSONATE_XML = xml_asset_path("auth_sign_in_impersonate.xml") +SIGN_IN_ERROR_XML = xml_asset_path("auth_sign_in_error.xml") class AuthTests(unittest.TestCase): diff --git a/test/test_custom_view.py b/test/test_custom_view.py index 6e863a863..71b614dcc 100644 --- a/test/test_custom_view.py +++ b/test/test_custom_view.py @@ -12,17 +12,17 @@ from tableauserverclient.datetime_helpers import format_datetime from tableauserverclient.server.endpoint.exceptions import MissingRequiredFieldError -TEST_ASSET_DIR = Path(__file__).parent / "assets" - -GET_XML = os.path.join(TEST_ASSET_DIR, "custom_view_get.xml") -GET_XML_ID = os.path.join(TEST_ASSET_DIR, "custom_view_get_id.xml") -POPULATE_PREVIEW_IMAGE = os.path.join(TEST_ASSET_DIR, "Sample View Image.png") -CUSTOM_VIEW_UPDATE_XML = os.path.join(TEST_ASSET_DIR, "custom_view_update.xml") -CUSTOM_VIEW_POPULATE_PDF = os.path.join(TEST_ASSET_DIR, "populate_pdf.pdf") -CUSTOM_VIEW_POPULATE_CSV = os.path.join(TEST_ASSET_DIR, "populate_csv.csv") -CUSTOM_VIEW_DOWNLOAD = TEST_ASSET_DIR / "custom_view_download.json" -FILE_UPLOAD_INIT = TEST_ASSET_DIR / "fileupload_initialize.xml" -FILE_UPLOAD_APPEND = TEST_ASSET_DIR / "fileupload_append.xml" +from test._utils import data_asset_path, xml_asset_path + +GET_XML = xml_asset_path("custom_view_get.xml") +GET_XML_ID = xml_asset_path("custom_view_get_id.xml") +POPULATE_PREVIEW_IMAGE = data_asset_path("Sample View Image.png") +CUSTOM_VIEW_UPDATE_XML = xml_asset_path("custom_view_update.xml") +CUSTOM_VIEW_POPULATE_PDF = data_asset_path("populate_pdf.pdf") +CUSTOM_VIEW_POPULATE_CSV = data_asset_path("populate_csv.csv") +CUSTOM_VIEW_DOWNLOAD = Path(xml_asset_path("custom_view_download.json")) +FILE_UPLOAD_INIT = Path(xml_asset_path("fileupload_initialize.xml")) +FILE_UPLOAD_APPEND = Path(xml_asset_path("fileupload_append.xml")) class CustomViewTests(unittest.TestCase): diff --git a/test/test_data_freshness_policy.py b/test/test_data_freshness_policy.py index 9591a6380..bd204d54f 100644 --- a/test/test_data_freshness_policy.py +++ b/test/test_data_freshness_policy.py @@ -3,15 +3,14 @@ import unittest import tableauserverclient as TSC - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -UPDATE_DFP_ALWAYS_LIVE_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy.xml") -UPDATE_DFP_SITE_DEFAULT_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy2.xml") -UPDATE_DFP_FRESH_EVERY_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy3.xml") -UPDATE_DFP_FRESH_AT_DAILY_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy4.xml") -UPDATE_DFP_FRESH_AT_WEEKLY_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy5.xml") -UPDATE_DFP_FRESH_AT_MONTHLY_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_data_freshness_policy6.xml") +from test._utils import xml_asset_path + +UPDATE_DFP_ALWAYS_LIVE_XML = xml_asset_path("workbook_update_data_freshness_policy.xml") +UPDATE_DFP_SITE_DEFAULT_XML = xml_asset_path("workbook_update_data_freshness_policy2.xml") +UPDATE_DFP_FRESH_EVERY_XML = xml_asset_path("workbook_update_data_freshness_policy3.xml") +UPDATE_DFP_FRESH_AT_DAILY_XML = xml_asset_path("workbook_update_data_freshness_policy4.xml") +UPDATE_DFP_FRESH_AT_WEEKLY_XML = xml_asset_path("workbook_update_data_freshness_policy5.xml") +UPDATE_DFP_FRESH_AT_MONTHLY_XML = xml_asset_path("workbook_update_data_freshness_policy6.xml") class WorkbookTests(unittest.TestCase): diff --git a/test/test_database.py b/test/test_database.py index 3fd2c9a67..e9e97323e 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -3,7 +3,7 @@ import requests_mock import tableauserverclient as TSC -from ._utils import read_xml_asset, asset +from ._utils import read_xml_asset GET_XML = "database_get.xml" POPULATE_PERMISSIONS_XML = "database_populate_permissions.xml" @@ -55,8 +55,7 @@ def test_update(self): self.assertEqual("Test", single_database.certification_note) def test_populate_permissions(self): - with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(POPULATE_PERMISSIONS_XML) with requests_mock.mock() as m: m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml) single_database = TSC.DatabaseItem("test") @@ -85,8 +84,7 @@ def test_populate_permissions(self): ) def test_populate_data_quality_warning(self): - with open(asset(GET_DQW_BY_CONTENT), "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(GET_DQW_BY_CONTENT) with requests_mock.mock() as m: m.get( self.server.databases._data_quality_warnings.baseurl + "/94441d26-9a52-4a42-b0fb-3f94792d1aac", diff --git a/test/test_datasource.py b/test/test_datasource.py index a604ba8b0..6cc30c842 100644 --- a/test/test_datasource.py +++ b/test/test_datasource.py @@ -14,7 +14,7 @@ from tableauserverclient.server.endpoint.exceptions import InternalServerError from tableauserverclient.server.endpoint.fileuploads_endpoint import Fileuploads from tableauserverclient.server.request_factory import RequestFactory -from ._utils import read_xml_asset, read_xml_assets, asset +from ._utils import data_asset_path, read_xml_asset, read_xml_assets, xml_asset_path ADD_TAGS_XML = "datasource_add_tags.xml" GET_XML = "datasource_get.xml" @@ -135,7 +135,7 @@ def test_update(self) -> None: self.assertEqual(updated_datasource.certification_note, single_datasource.certification_note) def test_update_copy_fields(self) -> None: - with open(asset(UPDATE_XML), "rb") as f: + with open(xml_asset_path(UPDATE_XML), "rb") as f: response_xml = f.read().decode("utf-8") with requests_mock.mock() as m: m.put(self.baseurl + "/9dbd2263-16b5-46e1-9c43-a76bb8ab65fb", text=response_xml) @@ -218,7 +218,7 @@ def test_update_connection(self) -> None: self.assertEqual("foo", new_connection.username) def test_populate_permissions(self) -> None: - with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f: + with open(xml_asset_path(POPULATE_PERMISSIONS_XML), "rb") as f: response_xml = f.read().decode("utf-8") with requests_mock.mock() as m: m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml) @@ -256,7 +256,9 @@ def test_publish(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "SampleDS") publish_mode = self.server.PublishMode.CreateNew - new_datasource = self.server.datasources.publish(new_datasource, asset("SampleDS.tds"), mode=publish_mode) + new_datasource = self.server.datasources.publish( + new_datasource, data_asset_path("SampleDS.tds"), mode=publish_mode + ) self.assertEqual("e76a1461-3b1d-4588-bf1b-17551a879ad9", new_datasource.id) self.assertEqual("SampleDS", new_datasource.name) @@ -275,7 +277,7 @@ def test_publish_a_non_packaged_file_object(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "SampleDS") publish_mode = self.server.PublishMode.CreateNew - with open(asset("SampleDS.tds"), "rb") as file_object: + with open(data_asset_path("SampleDS.tds"), "rb") as file_object: new_datasource = self.server.datasources.publish(new_datasource, file_object, mode=publish_mode) self.assertEqual("e76a1461-3b1d-4588-bf1b-17551a879ad9", new_datasource.id) @@ -298,7 +300,7 @@ def test_publish_a_packaged_file_object(self) -> None: # Create a dummy tdsx file in memory with BytesIO() as zip_archive: with ZipFile(zip_archive, "w") as zf: - zf.write(asset("SampleDS.tds")) + zf.write(data_asset_path("SampleDS.tds")) zip_archive.seek(0) @@ -324,7 +326,7 @@ def test_publish_async(self) -> None: publish_mode = self.server.PublishMode.CreateNew new_job = self.server.datasources.publish( - new_datasource, asset("SampleDS.tds"), mode=publish_mode, as_job=True + new_datasource, data_asset_path("SampleDS.tds"), mode=publish_mode, as_job=True ) self.assertEqual("9a373058-af5f-4f83-8662-98b3e0228a73", new_job.id) @@ -337,7 +339,7 @@ def test_publish_unnamed_file_object(self) -> None: new_datasource = TSC.DatasourceItem("test") publish_mode = self.server.PublishMode.CreateNew - with open(asset("SampleDS.tds"), "rb") as file_object: + with open(data_asset_path("SampleDS.tds"), "rb") as file_object: self.assertRaises(ValueError, self.server.datasources.publish, new_datasource, file_object, publish_mode) def test_refresh_id(self) -> None: @@ -466,7 +468,7 @@ def test_update_hyper_data_datasource_payload_file(self) -> None: text=response_xml, ) new_job = self.server.datasources.update_hyper_data( - datasource_id, request_id="test_id", actions=[], payload=asset("World Indicators.hyper") + datasource_id, request_id="test_id", actions=[], payload=data_asset_path("World Indicators.hyper") ) # We only check the `id`; remaining fields are already tested in `test_update_hyper_data_datasource_object` @@ -551,7 +553,9 @@ def test_publish_missing_path(self) -> None: def test_publish_missing_mode(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test") - self.assertRaises(ValueError, self.server.datasources.publish, new_datasource, asset("SampleDS.tds"), None) + self.assertRaises( + ValueError, self.server.datasources.publish, new_datasource, data_asset_path("SampleDS.tds"), None + ) def test_publish_invalid_file_type(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test") @@ -559,20 +563,20 @@ def test_publish_invalid_file_type(self) -> None: ValueError, self.server.datasources.publish, new_datasource, - asset("SampleWB.twbx"), + data_asset_path("SampleWB.twbx"), self.server.PublishMode.Append, ) def test_publish_hyper_file_object_raises_exception(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test") - with open(asset("World Indicators.hyper"), "rb") as file_object: + with open(data_asset_path("World Indicators.hyper"), "rb") as file_object: self.assertRaises( ValueError, self.server.datasources.publish, new_datasource, file_object, self.server.PublishMode.Append ) def test_publish_tde_file_object_raises_exception(self) -> None: new_datasource = TSC.DatasourceItem("ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", "test") - tds_asset = asset(os.path.join("Data", "Tableau Samples", "World Indicators.tde")) + tds_asset = data_asset_path("World Indicators.tde") with open(tds_asset, "rb") as file_object: self.assertRaises( ValueError, self.server.datasources.publish, new_datasource, file_object, self.server.PublishMode.Append @@ -645,7 +649,7 @@ def test_synchronous_publish_timeout_error(self) -> None: "Please use asynchronous publishing to avoid timeouts.", self.server.datasources.publish, new_datasource, - asset("SampleDS.tds"), + data_asset_path("SampleDS.tds"), publish_mode, ) diff --git a/test/test_filesys_helpers.py b/test/test_filesys_helpers.py index 0f3234d5d..455eaa622 100644 --- a/test/test_filesys_helpers.py +++ b/test/test_filesys_helpers.py @@ -5,7 +5,7 @@ from zipfile import ZipFile from tableauserverclient.filesys_helpers import get_file_object_size, get_file_type -from ._utils import asset, TEST_ASSET_DIR +from test._utils import data_asset_path class FilesysTests(unittest.TestCase): @@ -26,7 +26,7 @@ def test_get_file_size_returns_zero_for_empty_file(self): self.assertEqual(file_size, 0) def test_get_file_size_coincides_with_built_in_method(self): - asset_path = asset("SampleWB.twbx") + asset_path = data_asset_path("SampleWB.twbx") target_size = os.path.getsize(asset_path) with open(asset_path, "rb") as f: file_size = get_file_object_size(f) @@ -45,12 +45,12 @@ def test_get_file_type_identifies_a_zip_file(self): self.assertEqual(file_type, "zip") def test_get_file_type_identifies_tdsx_as_zip_file(self): - with open(asset("World Indicators.tdsx"), "rb") as file_object: + with open(data_asset_path("World Indicators.tdsx"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "zip") def test_get_file_type_identifies_twbx_as_zip_file(self): - with open(asset("SampleWB.twbx"), "rb") as file_object: + with open(data_asset_path("SampleWB.twbx"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "zip") @@ -69,23 +69,22 @@ def test_get_file_type_identifies_xml_file(self): self.assertEqual(file_type, "xml") def test_get_file_type_identifies_tds_as_xml_file(self): - with open(asset("World Indicators.tds"), "rb") as file_object: + with open(data_asset_path("World Indicators.tds"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "xml") def test_get_file_type_identifies_twb_as_xml_file(self): - with open(asset("RESTAPISample.twb"), "rb") as file_object: + with open(data_asset_path("RESTAPISample.twb"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "xml") def test_get_file_type_identifies_hyper_file(self): - with open(asset("World Indicators.hyper"), "rb") as file_object: + with open(data_asset_path("World Indicators.hyper"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "hyper") def test_get_file_type_identifies_tde_file(self): - asset_path = os.path.join(TEST_ASSET_DIR, "Data", "Tableau Samples", "World Indicators.tde") - with open(asset_path, "rb") as file_object: + with open(data_asset_path("World Indicators.tde"), "rb") as file_object: file_type = get_file_type(file_object) self.assertEqual(file_type, "tde") diff --git a/test/test_fileuploads.py b/test/test_fileuploads.py index 9567bc3ad..44c6f9fad 100644 --- a/test/test_fileuploads.py +++ b/test/test_fileuploads.py @@ -7,11 +7,10 @@ from tableauserverclient.config import BYTES_PER_MB, config from tableauserverclient.server import Server -from ._utils import asset +from test._utils import xml_asset_path, data_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") -FILEUPLOAD_INITIALIZE = os.path.join(TEST_ASSET_DIR, "fileupload_initialize.xml") -FILEUPLOAD_APPEND = os.path.join(TEST_ASSET_DIR, "fileupload_append.xml") +FILEUPLOAD_INITIALIZE = xml_asset_path("fileupload_initialize.xml") +FILEUPLOAD_APPEND = xml_asset_path("fileupload_append.xml") @contextlib.contextmanager @@ -36,19 +35,19 @@ def setUp(self): self.baseurl = f"{self.server.baseurl}/sites/{self.server.site_id}/fileUploads" def test_read_chunks_file_path(self): - file_path = asset("SampleWB.twbx") + file_path = data_asset_path("SampleWB.twbx") chunks = self.server.fileuploads._read_chunks(file_path) for chunk in chunks: self.assertIsNotNone(chunk) def test_read_chunks_file_object(self): - with open(asset("SampleWB.twbx"), "rb") as f: + with open(data_asset_path("SampleWB.twbx"), "rb") as f: chunks = self.server.fileuploads._read_chunks(f) for chunk in chunks: self.assertIsNotNone(chunk) def test_upload_chunks_file_path(self): - file_path = asset("SampleWB.twbx") + file_path = data_asset_path("SampleWB.twbx") upload_id = "7720:170fe6b1c1c7422dadff20f944d58a52-1:0" with open(FILEUPLOAD_INITIALIZE, "rb") as f: @@ -65,7 +64,7 @@ def test_upload_chunks_file_path(self): def test_upload_chunks_file_object(self): upload_id = "7720:170fe6b1c1c7422dadff20f944d58a52-1:0" - with open(asset("SampleWB.twbx"), "rb") as file_content: + with open(data_asset_path("SampleWB.twbx"), "rb") as file_content: with open(FILEUPLOAD_INITIALIZE, "rb") as f: initialize_response_xml = f.read().decode("utf-8") with open(FILEUPLOAD_APPEND, "rb") as f: diff --git a/test/test_flow.py b/test/test_flow.py index d458bc77b..2ac1ba9ab 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -7,16 +7,14 @@ import tableauserverclient as TSC from tableauserverclient.datetime_helpers import format_datetime -from ._utils import read_xml_asset, asset +from test._utils import data_asset_path, read_xml_asset, xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = os.path.join(TEST_ASSET_DIR, "flow_get.xml") -POPULATE_CONNECTIONS_XML = os.path.join(TEST_ASSET_DIR, "flow_populate_connections.xml") -POPULATE_PERMISSIONS_XML = os.path.join(TEST_ASSET_DIR, "flow_populate_permissions.xml") -PUBLISH_XML = os.path.join(TEST_ASSET_DIR, "flow_publish.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "flow_update.xml") -REFRESH_XML = os.path.join(TEST_ASSET_DIR, "flow_refresh.xml") +GET_XML = xml_asset_path("flow_get.xml") +POPULATE_CONNECTIONS_XML = xml_asset_path("flow_populate_connections.xml") +POPULATE_PERMISSIONS_XML = xml_asset_path("flow_populate_permissions.xml") +PUBLISH_XML = xml_asset_path("flow_publish.xml") +UPDATE_XML = xml_asset_path("flow_update.xml") +REFRESH_XML = xml_asset_path("flow_refresh.xml") class FlowTests(unittest.TestCase): @@ -122,8 +120,7 @@ def test_populate_connections(self) -> None: self.assertEqual(True, conn3.embed_password) def test_populate_permissions(self) -> None: - with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(POPULATE_PERMISSIONS_XML) with requests_mock.mock() as m: m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml) single_datasource = TSC.FlowItem("test") @@ -153,14 +150,13 @@ def test_populate_permissions(self) -> None: ) def test_publish(self) -> None: - with open(PUBLISH_XML, "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(PUBLISH_XML) with requests_mock.mock() as m: m.post(self.baseurl, text=response_xml) new_flow = TSC.FlowItem(name="SampleFlow", project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760") - sample_flow = os.path.join(TEST_ASSET_DIR, "SampleFlow.tfl") + sample_flow = data_asset_path("SampleFlow.tfl") publish_mode = self.server.PublishMode.CreateNew new_flow = self.server.flows.publish(new_flow, sample_flow, publish_mode) @@ -174,14 +170,13 @@ def test_publish(self) -> None: self.assertEqual("5de011f8-5aa9-4d5b-b991-f462c8dd6bb7", new_flow.owner_id) def test_publish_file_object(self) -> None: - with open(PUBLISH_XML, "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(PUBLISH_XML) with requests_mock.mock() as m: m.post(self.baseurl, text=response_xml) new_flow = TSC.FlowItem(name="SampleFlow", project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760") - sample_flow = os.path.join(TEST_ASSET_DIR, "SampleFlow.tfl") + sample_flow = data_asset_path("SampleFlow.tfl") publish_mode = self.server.PublishMode.CreateNew with open(sample_flow, "rb") as fp: @@ -198,8 +193,7 @@ def test_publish_file_object(self) -> None: self.assertEqual("5de011f8-5aa9-4d5b-b991-f462c8dd6bb7", new_flow.owner_id) def test_refresh(self): - with open(asset(REFRESH_XML), "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(REFRESH_XML) with requests_mock.mock() as m: m.post(self.baseurl + "/92967d2d-c7e2-46d0-8847-4802df58f484/run", text=response_xml) flow_item = TSC.FlowItem("test") diff --git a/test/test_flowtask.py b/test/test_flowtask.py index 2d9f7c7bd..eb464d2c5 100644 --- a/test/test_flowtask.py +++ b/test/test_flowtask.py @@ -6,11 +6,11 @@ import requests_mock import tableauserverclient as TSC -from tableauserverclient.datetime_helpers import parse_datetime from tableauserverclient.models.task_item import TaskItem -TEST_ASSET_DIR = Path(__file__).parent / "assets" -GET_XML_CREATE_FLOW_TASK_RESPONSE = os.path.join(TEST_ASSET_DIR, "tasks_create_flow_task.xml") +from test._utils import xml_asset_path, read_xml_asset + +GET_XML_CREATE_FLOW_TASK_RESPONSE = xml_asset_path("tasks_create_flow_task.xml") class TaskTests(unittest.TestCase): @@ -37,8 +37,7 @@ def test_create_flow_task(self): task = TaskItem(None, "RunFlow", None, schedule_item=monthly_schedule, target=target_item) - with open(GET_XML_CREATE_FLOW_TASK_RESPONSE, "rb") as f: - response_xml = f.read().decode("utf-8") + response_xml = read_xml_asset(GET_XML_CREATE_FLOW_TASK_RESPONSE) with requests_mock.mock() as m: m.post(f"{self.baseurl}", text=response_xml) create_response_content = self.server.flow_tasks.create(task).decode("utf-8") diff --git a/test/test_group.py b/test/test_group.py index b3de07963..fd3e9b8b7 100644 --- a/test/test_group.py +++ b/test/test_group.py @@ -1,26 +1,23 @@ -from pathlib import Path import unittest -import os import requests_mock import tableauserverclient as TSC +from pathlib import Path from tableauserverclient.datetime_helpers import format_datetime -TEST_ASSET_DIR = Path(__file__).absolute().parent / "assets" - -# TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = os.path.join(TEST_ASSET_DIR, "group_get.xml") -GET_XML_ALL_FIELDS = TEST_ASSET_DIR / "group_get_all_fields.xml" -POPULATE_USERS = os.path.join(TEST_ASSET_DIR, "group_populate_users.xml") -POPULATE_USERS_EMPTY = os.path.join(TEST_ASSET_DIR, "group_populate_users_empty.xml") -ADD_USER = os.path.join(TEST_ASSET_DIR, "group_add_user.xml") -ADD_USERS = TEST_ASSET_DIR / "group_add_users.xml" -ADD_USER_POPULATE = os.path.join(TEST_ASSET_DIR, "group_users_added.xml") -CREATE_GROUP = os.path.join(TEST_ASSET_DIR, "group_create.xml") -CREATE_GROUP_AD = os.path.join(TEST_ASSET_DIR, "group_create_ad.xml") -CREATE_GROUP_ASYNC = os.path.join(TEST_ASSET_DIR, "group_create_async.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "group_update.xml") -UPDATE_ASYNC_XML = TEST_ASSET_DIR / "group_update_async.xml" +from test._utils import data_asset_path, read_xml_asset, xml_asset_path + +GET_XML = xml_asset_path("group_get.xml") +GET_XML_ALL_FIELDS = Path(xml_asset_path("group_get_all_fields.xml")) +POPULATE_USERS = xml_asset_path("group_populate_users.xml") +POPULATE_USERS_EMPTY = xml_asset_path("group_populate_users_empty.xml") +ADD_USER = xml_asset_path("group_add_user.xml") +ADD_USERS = Path(xml_asset_path("group_add_users.xml")) +ADD_USER_POPULATE = xml_asset_path("group_users_added.xml") +CREATE_GROUP = xml_asset_path("group_create.xml") +CREATE_GROUP_AD = xml_asset_path("group_create_ad.xml") +CREATE_GROUP_ASYNC = xml_asset_path("group_create_async.xml") +UPDATE_XML = xml_asset_path("group_update.xml") +UPDATE_ASYNC_XML = Path(xml_asset_path("group_update_async.xml")) class GroupTests(unittest.TestCase): diff --git a/test/test_groupsets.py b/test/test_groupsets.py index 5479809d2..f7e58f503 100644 --- a/test/test_groupsets.py +++ b/test/test_groupsets.py @@ -1,17 +1,17 @@ -from pathlib import Path import unittest - +from pathlib import Path from defusedxml.ElementTree import fromstring import requests_mock import tableauserverclient as TSC from tableauserverclient.models.reference_item import ResourceReference -TEST_ASSET_DIR = Path(__file__).parent / "assets" -GROUPSET_CREATE = TEST_ASSET_DIR / "groupsets_create.xml" -GROUPSETS_GET = TEST_ASSET_DIR / "groupsets_get.xml" -GROUPSET_GET_BY_ID = TEST_ASSET_DIR / "groupsets_get_by_id.xml" -GROUPSET_UPDATE = TEST_ASSET_DIR / "groupsets_get_by_id.xml" +from test._utils import xml_asset_path + +GROUPSET_CREATE = Path(xml_asset_path("groupsets_create.xml")) +GROUPSETS_GET = Path(xml_asset_path("groupsets_get.xml")) +GROUPSET_GET_BY_ID = Path(xml_asset_path("groupsets_get_by_id.xml")) +GROUPSET_UPDATE = Path(xml_asset_path("groupsets_get_by_id.xml")) class TestGroupSets(unittest.TestCase): diff --git a/test/test_metadata.py b/test/test_metadata.py index 1dc9cf1c6..caa799e7f 100644 --- a/test/test_metadata.py +++ b/test/test_metadata.py @@ -1,21 +1,19 @@ import json -import os.path import unittest import requests_mock import tableauserverclient as TSC from tableauserverclient.server.endpoint.exceptions import GraphQLError +from test._utils import data_asset_path, xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") +METADATA_QUERY_SUCCESS = xml_asset_path("metadata_query_success.json") +METADATA_QUERY_ERROR = xml_asset_path("metadata_query_error.json") +EXPECTED_PAGED_DICT = xml_asset_path("metadata_query_expected_dict.dict") -METADATA_QUERY_SUCCESS = os.path.join(TEST_ASSET_DIR, "metadata_query_success.json") -METADATA_QUERY_ERROR = os.path.join(TEST_ASSET_DIR, "metadata_query_error.json") -EXPECTED_PAGED_DICT = os.path.join(TEST_ASSET_DIR, "metadata_query_expected_dict.dict") - -METADATA_PAGE_1 = os.path.join(TEST_ASSET_DIR, "metadata_paged_1.json") -METADATA_PAGE_2 = os.path.join(TEST_ASSET_DIR, "metadata_paged_2.json") -METADATA_PAGE_3 = os.path.join(TEST_ASSET_DIR, "metadata_paged_3.json") +METADATA_PAGE_1 = xml_asset_path("metadata_paged_1.json") +METADATA_PAGE_2 = xml_asset_path("metadata_paged_2.json") +METADATA_PAGE_3 = xml_asset_path("metadata_paged_3.json") EXPECTED_DICT = { "publishedDatasources": [ diff --git a/test/test_pager.py b/test/test_pager.py index 1836095bb..7d48a971d 100644 --- a/test/test_pager.py +++ b/test/test_pager.py @@ -7,13 +7,12 @@ import tableauserverclient as TSC from tableauserverclient.config import config +from test._utils import xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_VIEW_XML = os.path.join(TEST_ASSET_DIR, "view_get.xml") -GET_XML_PAGE1 = os.path.join(TEST_ASSET_DIR, "workbook_get_page_1.xml") -GET_XML_PAGE2 = os.path.join(TEST_ASSET_DIR, "workbook_get_page_2.xml") -GET_XML_PAGE3 = os.path.join(TEST_ASSET_DIR, "workbook_get_page_3.xml") +GET_VIEW_XML = xml_asset_path("view_get.xml") +GET_XML_PAGE1 = xml_asset_path("workbook_get_page_1.xml") +GET_XML_PAGE2 = xml_asset_path("workbook_get_page_2.xml") +GET_XML_PAGE3 = xml_asset_path("workbook_get_page_3.xml") @contextlib.contextmanager diff --git a/test/test_project.py b/test/test_project.py index c51f2e1e6..b5a3ebe8c 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -5,20 +5,22 @@ import tableauserverclient as TSC from tableauserverclient import GroupItem -from ._utils import read_xml_asset, asset - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = asset("project_get.xml") -GET_XML_ALL_FIELDS = asset("project_get_all_fields.xml") -UPDATE_XML = asset("project_update.xml") -SET_CONTENT_PERMISSIONS_XML = asset("project_content_permission.xml") -CREATE_XML = asset("project_create.xml") -POPULATE_PERMISSIONS_XML = "project_populate_permissions.xml" -POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML = "project_populate_workbook_default_permissions.xml" -UPDATE_DATASOURCE_DEFAULT_PERMISSIONS_XML = "project_update_datasource_default_permissions.xml" -POPULATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = "project_populate_virtualconnection_default_permissions.xml" -UPDATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = "project_update_virtualconnection_default_permissions.xml" +from ._utils import read_xml_asset, xml_asset_path + +GET_XML = xml_asset_path("project_get.xml") +GET_XML_ALL_FIELDS = xml_asset_path("project_get_all_fields.xml") +UPDATE_XML = xml_asset_path("project_update.xml") +SET_CONTENT_PERMISSIONS_XML = xml_asset_path("project_content_permission.xml") +CREATE_XML = xml_asset_path("project_create.xml") +POPULATE_PERMISSIONS_XML = xml_asset_path("project_populate_permissions.xml") +POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_populate_workbook_default_permissions.xml") +UPDATE_DATASOURCE_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_update_datasource_default_permissions.xml") +POPULATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = xml_asset_path( + "project_populate_virtualconnection_default_permissions.xml" +) +UPDATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = xml_asset_path( + "project_update_virtualconnection_default_permissions.xml" +) class ProjectTests(unittest.TestCase): @@ -163,7 +165,7 @@ def test_create_missing_name(self) -> None: TSC.ProjectItem() def test_populate_permissions(self) -> None: - with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f: + with open(POPULATE_PERMISSIONS_XML, "rb") as f: response_xml = f.read().decode("utf-8") with requests_mock.mock() as m: m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml) @@ -221,7 +223,7 @@ def test_populate_workbooks(self) -> None: ) def test_delete_permission(self) -> None: - with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f: + with open(xml_asset_path(POPULATE_PERMISSIONS_XML), "rb") as f: response_xml = f.read().decode("utf-8") with requests_mock.mock() as m: m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml) @@ -250,7 +252,7 @@ def test_delete_permission(self) -> None: self.server.projects.delete_permission(item=single_project, rules=rules) def test_delete_workbook_default_permission(self) -> None: - with open(asset(POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML), "rb") as f: + with open(xml_asset_path(POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML), "rb") as f: response_xml = f.read().decode("utf-8") with requests_mock.mock() as m: diff --git a/test/test_request_option.py b/test/test_request_option.py index 57dfdc2a0..be41c9b40 100644 --- a/test/test_request_option.py +++ b/test/test_request_option.py @@ -7,19 +7,18 @@ import requests_mock import tableauserverclient as TSC - -TEST_ASSET_DIR = Path(__file__).parent / "assets" - -PAGINATION_XML = os.path.join(TEST_ASSET_DIR, "request_option_pagination.xml") -PAGE_NUMBER_XML = os.path.join(TEST_ASSET_DIR, "request_option_page_number.xml") -PAGE_SIZE_XML = os.path.join(TEST_ASSET_DIR, "request_option_page_size.xml") -FILTER_EQUALS = os.path.join(TEST_ASSET_DIR, "request_option_filter_equals.xml") -FILTER_NAME_IN = os.path.join(TEST_ASSET_DIR, "request_option_filter_name_in.xml") -FILTER_TAGS_IN = os.path.join(TEST_ASSET_DIR, "request_option_filter_tags_in.xml") -FILTER_MULTIPLE = os.path.join(TEST_ASSET_DIR, "request_option_filter_tags_in.xml") -SLICING_QUERYSET = os.path.join(TEST_ASSET_DIR, "request_option_slicing_queryset.xml") -SLICING_QUERYSET_PAGE_1 = TEST_ASSET_DIR / "queryset_slicing_page_1.xml" -SLICING_QUERYSET_PAGE_2 = TEST_ASSET_DIR / "queryset_slicing_page_2.xml" +from test._utils import xml_asset_path + +PAGINATION_XML = xml_asset_path("request_option_pagination.xml") +PAGE_NUMBER_XML = xml_asset_path("request_option_page_number.xml") +PAGE_SIZE_XML = xml_asset_path("request_option_page_size.xml") +FILTER_EQUALS = xml_asset_path("request_option_filter_equals.xml") +FILTER_NAME_IN = xml_asset_path("request_option_filter_name_in.xml") +FILTER_TAGS_IN = xml_asset_path("request_option_filter_tags_in.xml") +FILTER_MULTIPLE = xml_asset_path("request_option_filter_tags_in.xml") +SLICING_QUERYSET = xml_asset_path("request_option_slicing_queryset.xml") +SLICING_QUERYSET_PAGE_1 = Path(xml_asset_path("queryset_slicing_page_1.xml")) +SLICING_QUERYSET_PAGE_2 = Path(xml_asset_path("queryset_slicing_page_2.xml")) class RequestOptionTests(unittest.TestCase): diff --git a/test/test_schedule.py b/test/test_schedule.py index 4fcc85e18..4514b7c53 100644 --- a/test/test_schedule.py +++ b/test/test_schedule.py @@ -6,30 +6,29 @@ import tableauserverclient as TSC from tableauserverclient.datetime_helpers import format_datetime - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = os.path.join(TEST_ASSET_DIR, "schedule_get.xml") -GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_by_id.xml") -GET_HOURLY_ID_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_hourly_id.xml") -GET_DAILY_ID_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_daily_id.xml") -GET_MONTHLY_ID_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_monthly_id.xml") -GET_MONTHLY_ID_2_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_monthly_id_2.xml") -GET_EMPTY_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_empty.xml") -CREATE_HOURLY_XML = os.path.join(TEST_ASSET_DIR, "schedule_create_hourly.xml") -CREATE_DAILY_XML = os.path.join(TEST_ASSET_DIR, "schedule_create_daily.xml") -CREATE_WEEKLY_XML = os.path.join(TEST_ASSET_DIR, "schedule_create_weekly.xml") -CREATE_MONTHLY_XML = os.path.join(TEST_ASSET_DIR, "schedule_create_monthly.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "schedule_update.xml") -ADD_WORKBOOK_TO_SCHEDULE = os.path.join(TEST_ASSET_DIR, "schedule_add_workbook.xml") -ADD_WORKBOOK_TO_SCHEDULE_WITH_WARNINGS = os.path.join(TEST_ASSET_DIR, "schedule_add_workbook_with_warnings.xml") -ADD_DATASOURCE_TO_SCHEDULE = os.path.join(TEST_ASSET_DIR, "schedule_add_datasource.xml") -ADD_FLOW_TO_SCHEDULE = os.path.join(TEST_ASSET_DIR, "schedule_add_flow.xml") -GET_EXTRACT_TASKS_XML = os.path.join(TEST_ASSET_DIR, "schedule_get_extract_refresh_tasks.xml") - -WORKBOOK_GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_by_id.xml") -DATASOURCE_GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "datasource_get_by_id.xml") -FLOW_GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "flow_get_by_id.xml") +from test._utils import xml_asset_path + +GET_XML = xml_asset_path("schedule_get.xml") +GET_BY_ID_XML = xml_asset_path("schedule_get_by_id.xml") +GET_HOURLY_ID_XML = xml_asset_path("schedule_get_hourly_id.xml") +GET_DAILY_ID_XML = xml_asset_path("schedule_get_daily_id.xml") +GET_MONTHLY_ID_XML = xml_asset_path("schedule_get_monthly_id.xml") +GET_MONTHLY_ID_2_XML = xml_asset_path("schedule_get_monthly_id_2.xml") +GET_EMPTY_XML = xml_asset_path("schedule_get_empty.xml") +CREATE_HOURLY_XML = xml_asset_path("schedule_create_hourly.xml") +CREATE_DAILY_XML = xml_asset_path("schedule_create_daily.xml") +CREATE_WEEKLY_XML = xml_asset_path("schedule_create_weekly.xml") +CREATE_MONTHLY_XML = xml_asset_path("schedule_create_monthly.xml") +UPDATE_XML = xml_asset_path("schedule_update.xml") +ADD_WORKBOOK_TO_SCHEDULE = xml_asset_path("schedule_add_workbook.xml") +ADD_WORKBOOK_TO_SCHEDULE_WITH_WARNINGS = xml_asset_path("schedule_add_workbook_with_warnings.xml") +ADD_DATASOURCE_TO_SCHEDULE = xml_asset_path("schedule_add_datasource.xml") +ADD_FLOW_TO_SCHEDULE = xml_asset_path("schedule_add_flow.xml") +GET_EXTRACT_TASKS_XML = xml_asset_path("schedule_get_extract_refresh_tasks.xml") + +WORKBOOK_GET_BY_ID_XML = xml_asset_path("workbook_get_by_id.xml") +DATASOURCE_GET_BY_ID_XML = xml_asset_path("datasource_get_by_id.xml") +FLOW_GET_BY_ID_XML = xml_asset_path("flow_get_by_id.xml") class ScheduleTests(unittest.TestCase): diff --git a/test/test_server_info.py b/test/test_server_info.py index fa1472c9a..8326e125f 100644 --- a/test/test_server_info.py +++ b/test/test_server_info.py @@ -1,18 +1,16 @@ -import os.path import unittest import requests_mock import tableauserverclient as TSC from tableauserverclient.server.endpoint.exceptions import NonXMLResponseError +from test._utils import xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -SERVER_INFO_GET_XML = os.path.join(TEST_ASSET_DIR, "server_info_get.xml") -SERVER_INFO_25_XML = os.path.join(TEST_ASSET_DIR, "server_info_25.xml") -SERVER_INFO_404 = os.path.join(TEST_ASSET_DIR, "server_info_404.xml") -SERVER_INFO_AUTH_INFO_XML = os.path.join(TEST_ASSET_DIR, "server_info_auth_info.xml") -SERVER_INFO_WRONG_SITE = os.path.join(TEST_ASSET_DIR, "server_info_wrong_site.html") +SERVER_INFO_GET_XML = xml_asset_path("server_info_get.xml") +SERVER_INFO_25_XML = xml_asset_path("server_info_25.xml") +SERVER_INFO_404 = xml_asset_path("server_info_404.xml") +SERVER_INFO_AUTH_INFO_XML = xml_asset_path("server_info_auth_info.xml") +SERVER_INFO_WRONG_SITE = xml_asset_path("server_info_wrong_site.html") class ServerInfoTests(unittest.TestCase): diff --git a/test/test_site.py b/test/test_site.py index 243810254..028b432c2 100644 --- a/test/test_site.py +++ b/test/test_site.py @@ -1,19 +1,17 @@ -import os.path import unittest import pytest import requests_mock import tableauserverclient as TSC - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = os.path.join(TEST_ASSET_DIR, "site_get.xml") -GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "site_get_by_id.xml") -GET_BY_NAME_XML = os.path.join(TEST_ASSET_DIR, "site_get_by_name.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "site_update.xml") -CREATE_XML = os.path.join(TEST_ASSET_DIR, "site_create.xml") -SITE_AUTH_CONFIG_XML = os.path.join(TEST_ASSET_DIR, "site_auth_configurations.xml") +from test._utils import xml_asset_path + +GET_XML = xml_asset_path("site_get.xml") +GET_BY_ID_XML = xml_asset_path("site_get_by_id.xml") +GET_BY_NAME_XML = xml_asset_path("site_get_by_name.xml") +UPDATE_XML = xml_asset_path("site_update.xml") +CREATE_XML = xml_asset_path("site_create.xml") +SITE_AUTH_CONFIG_XML = xml_asset_path("site_auth_configurations.xml") class SiteTests(unittest.TestCase): diff --git a/test/test_subscription.py b/test/test_subscription.py index 45dcb0a1c..7ce6c313e 100644 --- a/test/test_subscription.py +++ b/test/test_subscription.py @@ -4,12 +4,11 @@ import requests_mock import tableauserverclient as TSC +from test._utils import xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -CREATE_XML = os.path.join(TEST_ASSET_DIR, "subscription_create.xml") -GET_XML = os.path.join(TEST_ASSET_DIR, "subscription_get.xml") -GET_XML_BY_ID = os.path.join(TEST_ASSET_DIR, "subscription_get_by_id.xml") +CREATE_XML = xml_asset_path("subscription_create.xml") +GET_XML = xml_asset_path("subscription_get.xml") +GET_XML_BY_ID = xml_asset_path("subscription_get_by_id.xml") class SubscriptionTests(unittest.TestCase): diff --git a/test/test_tagging.py b/test/test_tagging.py index 23dffebfb..b9bba4f17 100644 --- a/test/test_tagging.py +++ b/test/test_tagging.py @@ -9,6 +9,7 @@ import tableauserverclient as TSC +# This whole suite seems slow. Is there some excessive setup, or something we can pull out into a onetime setup? @pytest.fixture def get_server() -> TSC.Server: server = TSC.Server("http://test", False) @@ -114,7 +115,10 @@ def make_vconn() -> TSC.VirtualConnectionItem: ["a", "b", "c", "c"], ] - +""" +The standalone add and delete tests are redundant with the update tests. +Given that this is low-pri functionality and this test suite is already slow, +let's not run them by default @pytest.mark.parametrize("endpoint_type, item", *sample_taggable_items) @pytest.mark.parametrize("tags", sample_tags) def test_add_tags(get_server, endpoint_type, item, tags) -> None: @@ -160,6 +164,7 @@ def test_delete_tags(get_server, endpoint_type, item, tags) -> None: assert len(history) == len(tag_set) urls = {r.url.split("/")[-1] for r in history} assert urls == tag_set +""" @pytest.mark.parametrize("endpoint_type, item", *sample_taggable_items) diff --git a/test/test_task.py b/test/test_task.py index 2d724b879..947f85de0 100644 --- a/test/test_task.py +++ b/test/test_task.py @@ -1,25 +1,23 @@ -import os import unittest from datetime import time from pathlib import Path - import requests_mock import tableauserverclient as TSC from tableauserverclient.datetime_helpers import parse_datetime from tableauserverclient.models.task_item import TaskItem -TEST_ASSET_DIR = Path(__file__).parent / "assets" - -GET_XML_NO_WORKBOOK = os.path.join(TEST_ASSET_DIR, "tasks_no_workbook_or_datasource.xml") -GET_XML_WITH_WORKBOOK = os.path.join(TEST_ASSET_DIR, "tasks_with_workbook.xml") -GET_XML_WITH_DATASOURCE = os.path.join(TEST_ASSET_DIR, "tasks_with_datasource.xml") -GET_XML_WITH_WORKBOOK_AND_DATASOURCE = os.path.join(TEST_ASSET_DIR, "tasks_with_workbook_and_datasource.xml") -GET_XML_DATAACCELERATION_TASK = os.path.join(TEST_ASSET_DIR, "tasks_with_dataacceleration_task.xml") -GET_XML_RUN_NOW_RESPONSE = os.path.join(TEST_ASSET_DIR, "tasks_run_now_response.xml") -GET_XML_CREATE_TASK_RESPONSE = os.path.join(TEST_ASSET_DIR, "tasks_create_extract_task.xml") -GET_XML_WITHOUT_SCHEDULE = TEST_ASSET_DIR / "tasks_without_schedule.xml" -GET_XML_WITH_INTERVAL = TEST_ASSET_DIR / "tasks_with_interval.xml" +from test._utils import xml_asset_path + +GET_XML_NO_WORKBOOK = xml_asset_path("tasks_no_workbook_or_datasource.xml") +GET_XML_WITH_WORKBOOK = xml_asset_path("tasks_with_workbook.xml") +GET_XML_WITH_DATASOURCE = xml_asset_path("tasks_with_datasource.xml") +GET_XML_WITH_WORKBOOK_AND_DATASOURCE = xml_asset_path("tasks_with_workbook_and_datasource.xml") +GET_XML_DATAACCELERATION_TASK = xml_asset_path("tasks_with_dataacceleration_task.xml") +GET_XML_RUN_NOW_RESPONSE = xml_asset_path("tasks_run_now_response.xml") +GET_XML_CREATE_TASK_RESPONSE = xml_asset_path("tasks_create_extract_task.xml") +GET_XML_WITHOUT_SCHEDULE = Path(xml_asset_path("tasks_without_schedule.xml")) +GET_XML_WITH_INTERVAL = Path(xml_asset_path("tasks_with_interval.xml")) class TaskTests(unittest.TestCase): diff --git a/test/test_user.py b/test/test_user.py index fa2ac3a12..072b1ba1e 100644 --- a/test/test_user.py +++ b/test/test_user.py @@ -6,21 +6,20 @@ import tableauserverclient as TSC from tableauserverclient.datetime_helpers import format_datetime, parse_datetime - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = os.path.join(TEST_ASSET_DIR, "user_get.xml") -GET_XML_ALL_FIELDS = os.path.join(TEST_ASSET_DIR, "user_get_all_fields.xml") -GET_EMPTY_XML = os.path.join(TEST_ASSET_DIR, "user_get_empty.xml") -GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "user_get_by_id.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "user_update.xml") -ADD_XML = os.path.join(TEST_ASSET_DIR, "user_add.xml") -POPULATE_WORKBOOKS_XML = os.path.join(TEST_ASSET_DIR, "user_populate_workbooks.xml") -GET_FAVORITES_XML = os.path.join(TEST_ASSET_DIR, "favorites_get.xml") -POPULATE_GROUPS_XML = os.path.join(TEST_ASSET_DIR, "user_populate_groups.xml") - -USERNAMES = os.path.join(TEST_ASSET_DIR, "Data", "usernames.csv") -USERS = os.path.join(TEST_ASSET_DIR, "Data", "user_details.csv") +from test._utils import data_asset_path, xml_asset_path + +GET_XML = xml_asset_path("user_get.xml") +GET_XML_ALL_FIELDS = xml_asset_path("user_get_all_fields.xml") +GET_EMPTY_XML = xml_asset_path("user_get_empty.xml") +GET_BY_ID_XML = xml_asset_path("user_get_by_id.xml") +UPDATE_XML = xml_asset_path("user_update.xml") +ADD_XML = xml_asset_path("user_add.xml") +POPULATE_WORKBOOKS_XML = xml_asset_path("user_populate_workbooks.xml") +GET_FAVORITES_XML = xml_asset_path("favorites_get.xml") +POPULATE_GROUPS_XML = xml_asset_path("user_populate_groups.xml") + +USERNAMES = data_asset_path("usernames.csv") +USERS = data_asset_path("user_details.csv") class UserTests(unittest.TestCase): diff --git a/test/test_view.py b/test/test_view.py index ee6d518de..38b516069 100644 --- a/test/test_view.py +++ b/test/test_view.py @@ -7,22 +7,21 @@ from tableauserverclient import UserItem, GroupItem, PermissionsRule from tableauserverclient.datetime_helpers import format_datetime, parse_datetime from tableauserverclient.server.endpoint.exceptions import UnsupportedAttributeError - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -ADD_TAGS_XML = os.path.join(TEST_ASSET_DIR, "view_add_tags.xml") -GET_XML = os.path.join(TEST_ASSET_DIR, "view_get.xml") -GET_XML_ALL_FIELDS = os.path.join(TEST_ASSET_DIR, "view_get_all_fields.xml") -GET_XML_ID = os.path.join(TEST_ASSET_DIR, "view_get_id.xml") -GET_XML_USAGE = os.path.join(TEST_ASSET_DIR, "view_get_usage.xml") -GET_XML_ID_USAGE = os.path.join(TEST_ASSET_DIR, "view_get_id_usage.xml") -POPULATE_PREVIEW_IMAGE = os.path.join(TEST_ASSET_DIR, "Sample View Image.png") -POPULATE_PDF = os.path.join(TEST_ASSET_DIR, "populate_pdf.pdf") -POPULATE_CSV = os.path.join(TEST_ASSET_DIR, "populate_csv.csv") -POPULATE_EXCEL = os.path.join(TEST_ASSET_DIR, "populate_excel.xlsx") -POPULATE_PERMISSIONS_XML = os.path.join(TEST_ASSET_DIR, "view_populate_permissions.xml") -UPDATE_PERMISSIONS = os.path.join(TEST_ASSET_DIR, "view_update_permissions.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "workbook_update.xml") +from test._utils import data_asset_path, xml_asset_path + +ADD_TAGS_XML = xml_asset_path("view_add_tags.xml") +GET_XML = xml_asset_path("view_get.xml") +GET_XML_ALL_FIELDS = xml_asset_path("view_get_all_fields.xml") +GET_XML_ID = xml_asset_path("view_get_id.xml") +GET_XML_USAGE = xml_asset_path("view_get_usage.xml") +GET_XML_ID_USAGE = xml_asset_path("view_get_id_usage.xml") +POPULATE_PREVIEW_IMAGE = data_asset_path("Sample View Image.png") +POPULATE_PDF = data_asset_path("populate_pdf.pdf") +POPULATE_CSV = data_asset_path("populate_csv.csv") +POPULATE_EXCEL = data_asset_path("populate_excel.xlsx") +POPULATE_PERMISSIONS_XML = xml_asset_path("view_populate_permissions.xml") +UPDATE_PERMISSIONS = xml_asset_path("view_update_permissions.xml") +UPDATE_XML = xml_asset_path("workbook_update.xml") class ViewTests(unittest.TestCase): diff --git a/test/test_view_acceleration.py b/test/test_view_acceleration.py index 766831b0a..f53a6e550 100644 --- a/test/test_view_acceleration.py +++ b/test/test_view_acceleration.py @@ -1,16 +1,14 @@ -import os import requests_mock import unittest import tableauserverclient as TSC from tableauserverclient.datetime_helpers import format_datetime +from test._utils import xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_BY_ID_ACCELERATION_STATUS_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_by_id_acceleration_status.xml") -POPULATE_VIEWS_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_views.xml") -UPDATE_VIEWS_ACCELERATION_STATUS_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_views_acceleration_status.xml") -UPDATE_WORKBOOK_ACCELERATION_STATUS_XML = os.path.join(TEST_ASSET_DIR, "workbook_update_acceleration_status.xml") +GET_BY_ID_ACCELERATION_STATUS_XML = xml_asset_path("workbook_get_by_id_acceleration_status.xml") +POPULATE_VIEWS_XML = xml_asset_path("workbook_populate_views.xml") +UPDATE_VIEWS_ACCELERATION_STATUS_XML = xml_asset_path("workbook_update_views_acceleration_status.xml") +UPDATE_WORKBOOK_ACCELERATION_STATUS_XML = xml_asset_path("workbook_update_acceleration_status.xml") class WorkbookTests(unittest.TestCase): diff --git a/test/test_webhook.py b/test/test_webhook.py index 5f26266b2..02412e372 100644 --- a/test/test_webhook.py +++ b/test/test_webhook.py @@ -6,13 +6,11 @@ import tableauserverclient as TSC from tableauserverclient.server import RequestFactory from tableauserverclient.models import WebhookItem -from ._utils import asset +from test._utils import xml_asset_path -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -GET_XML = asset("webhook_get.xml") -CREATE_XML = asset("webhook_create.xml") -CREATE_REQUEST_XML = asset("webhook_create_request.xml") +GET_XML = xml_asset_path("webhook_get.xml") +CREATE_XML = xml_asset_path("webhook_create.xml") +CREATE_REQUEST_XML = xml_asset_path("webhook_create_request.xml") class WebhookTests(unittest.TestCase): diff --git a/test/test_workbook.py b/test/test_workbook.py index 84afd7fcb..91076411f 100644 --- a/test/test_workbook.py +++ b/test/test_workbook.py @@ -14,31 +14,29 @@ from tableauserverclient.models import UserItem, GroupItem, PermissionsRule from tableauserverclient.server.endpoint.exceptions import InternalServerError, UnsupportedAttributeError from tableauserverclient.server.request_factory import RequestFactory -from ._utils import asset - -TEST_ASSET_DIR = os.path.join(os.path.dirname(__file__), "assets") - -ADD_TAGS_XML = os.path.join(TEST_ASSET_DIR, "workbook_add_tags.xml") -GET_BY_ID_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_by_id.xml") -GET_BY_ID_XML_PERSONAL = os.path.join(TEST_ASSET_DIR, "workbook_get_by_id_personal.xml") -GET_EMPTY_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_empty.xml") -GET_INVALID_DATE_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_invalid_date.xml") -GET_XML = os.path.join(TEST_ASSET_DIR, "workbook_get.xml") -GET_XML_ALL_FIELDS = os.path.join(TEST_ASSET_DIR, "workbook_get_all_fields.xml") -ODATA_XML = os.path.join(TEST_ASSET_DIR, "odata_connection.xml") -POPULATE_CONNECTIONS_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_connections.xml") -POPULATE_PDF = os.path.join(TEST_ASSET_DIR, "populate_pdf.pdf") -POPULATE_POWERPOINT = os.path.join(TEST_ASSET_DIR, "populate_powerpoint.pptx") -POPULATE_PERMISSIONS_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_permissions.xml") -POPULATE_PREVIEW_IMAGE = os.path.join(TEST_ASSET_DIR, "RESTAPISample Image.png") -POPULATE_VIEWS_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_views.xml") -POPULATE_VIEWS_USAGE_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_views_usage.xml") -PUBLISH_XML = os.path.join(TEST_ASSET_DIR, "workbook_publish.xml") -PUBLISH_ASYNC_XML = os.path.join(TEST_ASSET_DIR, "workbook_publish_async.xml") -REFRESH_XML = os.path.join(TEST_ASSET_DIR, "workbook_refresh.xml") -REVISION_XML = os.path.join(TEST_ASSET_DIR, "workbook_revision.xml") -UPDATE_XML = os.path.join(TEST_ASSET_DIR, "workbook_update.xml") -UPDATE_PERMISSIONS = os.path.join(TEST_ASSET_DIR, "workbook_update_permissions.xml") +from test._utils import data_asset_path, xml_asset_path, read_xml_asset + +ADD_TAGS_XML = xml_asset_path("workbook_add_tags.xml") +GET_BY_ID_XML = xml_asset_path("workbook_get_by_id.xml") +GET_BY_ID_XML_PERSONAL = xml_asset_path("workbook_get_by_id_personal.xml") +GET_EMPTY_XML = xml_asset_path("workbook_get_empty.xml") +GET_INVALID_DATE_XML = xml_asset_path("workbook_get_invalid_date.xml") +GET_XML = xml_asset_path("workbook_get.xml") +GET_XML_ALL_FIELDS = xml_asset_path("workbook_get_all_fields.xml") +ODATA_XML = xml_asset_path("odata_connection.xml") +POPULATE_CONNECTIONS_XML = xml_asset_path("workbook_populate_connections.xml") +POPULATE_PDF = xml_asset_path("populate_pdf.pdf") +POPULATE_POWERPOINT = xml_asset_path("populate_powerpoint.pptx") +POPULATE_PERMISSIONS_XML = xml_asset_path("workbook_populate_permissions.xml") +POPULATE_PREVIEW_IMAGE = data_asset_path("RESTAPISample Image.png") +POPULATE_VIEWS_XML = xml_asset_path("workbook_populate_views.xml") +POPULATE_VIEWS_USAGE_XML = xml_asset_path("workbook_populate_views_usage.xml") +PUBLISH_XML = xml_asset_path("workbook_publish.xml") +PUBLISH_ASYNC_XML = xml_asset_path("workbook_publish_async.xml") +REFRESH_XML = xml_asset_path("workbook_refresh.xml") +REVISION_XML = xml_asset_path("workbook_revision.xml") +UPDATE_XML = xml_asset_path("workbook_update.xml") +UPDATE_PERMISSIONS = xml_asset_path("workbook_update_permissions.xml") class WorkbookTests(unittest.TestCase): @@ -539,7 +537,7 @@ def test_publish(self) -> None: new_workbook.description = "REST API Testing" - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_workbook = self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode) @@ -569,7 +567,7 @@ def test_publish_a_packaged_file_object(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") with open(sample_workbook, "rb") as fp: publish_mode = self.server.PublishMode.CreateNew @@ -600,7 +598,7 @@ def test_publish_non_packeged_file_object(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "RESTAPISample.twb") + sample_workbook = data_asset_path("RESTAPISample.twb") with open(sample_workbook, "rb") as fp: publish_mode = self.server.PublishMode.CreateNew @@ -631,7 +629,7 @@ def test_publish_path_object(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = Path(TEST_ASSET_DIR) / "SampleWB.twbx" + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_workbook = self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode) @@ -660,7 +658,7 @@ def test_publish_with_hidden_views_on_workbook(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_workbook.hidden_views = ["GDP per capita"] @@ -683,7 +681,7 @@ def test_publish_with_thumbnails_user_id(self) -> None: thumbnails_user_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20761", ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_workbook = self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode) request_body = m._adapter.request_history[0]._request.body @@ -703,7 +701,7 @@ def test_publish_with_thumbnails_group_id(self) -> None: thumbnails_group_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20762", ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_workbook = self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode) request_body = m._adapter.request_history[0]._request.body @@ -720,7 +718,7 @@ def test_publish_with_query_params(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew self.server.workbooks.publish( @@ -745,7 +743,7 @@ def test_publish_async(self) -> None: name="Sample", show_tabs=False, project_id="ee8c6e70-43b6-11e6-af4f-f7b0d8e20760" ) - sample_workbook = os.path.join(TEST_ASSET_DIR, "SampleWB.twbx") + sample_workbook = data_asset_path("SampleWB.twbx") publish_mode = self.server.PublishMode.CreateNew new_job = self.server.workbooks.publish(new_workbook, sample_workbook, publish_mode, as_job=True) @@ -766,14 +764,14 @@ def test_publish_invalid_file_type(self) -> None: ValueError, self.server.workbooks.publish, new_workbook, - os.path.join(TEST_ASSET_DIR, "SampleDS.tds"), + data_asset_path("SampleDS.tds"), self.server.PublishMode.CreateNew, ) def test_publish_unnamed_file_object(self) -> None: new_workbook = TSC.WorkbookItem("test") - with open(os.path.join(TEST_ASSET_DIR, "SampleWB.twbx"), "rb") as f: + with open(data_asset_path("SampleWB.twbx"), "rb") as f: self.assertRaises( ValueError, self.server.workbooks.publish, new_workbook, f, self.server.PublishMode.CreateNew ) @@ -781,7 +779,7 @@ def test_publish_unnamed_file_object(self) -> None: def test_publish_non_bytes_file_object(self) -> None: new_workbook = TSC.WorkbookItem("test") - with open(os.path.join(TEST_ASSET_DIR, "SampleWB.twbx")) as f: + with open(data_asset_path("SampleWB.twbx")) as f: self.assertRaises( TypeError, self.server.workbooks.publish, new_workbook, f, self.server.PublishMode.CreateNew ) @@ -851,7 +849,7 @@ def test_synchronous_publish_timeout_error(self) -> None: "Please use asynchronous publishing to avoid timeouts", self.server.workbooks.publish, new_workbook, - asset("SampleWB.twbx"), + data_asset_path("SampleWB.twbx"), publish_mode, )