def test_TableauScraper_promptDropdown(mocker: MockerFixture) -> None: mocker.patch("tableauscraper.api.getTableauViz", return_value=tableauVizHtmlResponse) mocker.patch("tableauscraper.api.getTableauData", return_value=tableauDataResponse) mocker.patch("tableauscraper.api.setParameterValue", return_value=vqlCmdResponse) ts = TS() ts.loads(fakeUri) mocker.patch("builtins.input", side_effect=["0", "0", "0", ""]) tableauDataFrameGroup = ts.promptParameters() assert type(tableauDataFrameGroup) is TableauWorkbook assert len(tableauDataFrameGroup.worksheets) == 1 assert tableauDataFrameGroup.worksheets[0].name == "[WORKSHEET1]" assert tableauDataFrameGroup.worksheets[0].data.shape[0] == 4 assert tableauDataFrameGroup.worksheets[0].data.shape[1] == 2 assert list(tableauDataFrameGroup.worksheets[0].data.columns.values) == [ "[FIELD1]-value", "[FIELD2]-alias", ]
parser.add_argument("-url", "--url", help="full tableau url", required=True) args = parser.parse_args() ts = TS() ts.loads(args.url) # checkout the json data # with open('data.json', 'w', encoding='utf-8') as f: # json.dump(ts.data, f, ensure_ascii=False, indent=4) # with open('info.json', 'w', encoding='utf-8') as f: # json.dump(ts.info, f, ensure_ascii=False, indent=4) if args.get == "workbook": workbook = ts.promptDashboard() elif args.get == "parameter": workbook = ts.promptParameters() elif args.get == "select": workbook = ts.promptSelect() with pd.option_context( "display.max_rows", None, "display.max_columns", 5, "display.width", 1000 ): for idx, worksheet in enumerate(workbook.worksheets): if idx == 0: print("|" + ("-" * (os.get_terminal_size().columns - 2)) + "|") print("|" + worksheet.name.center(os.get_terminal_size().columns - 2) + "|") print("|" + ("-" * (os.get_terminal_size().columns - 2)) + "|") print(worksheet.data) print("") print("selectable values") # selectable values