|
5 | 5 |
|
6 | 6 | import tableauserverclient as TSC |
7 | 7 | from tableauserverclient.datetime_helpers import parse_datetime |
| 8 | +from ._utils import read_xml_asset |
8 | 9 |
|
9 | 10 | TEST_ASSET_DIR = Path(__file__).parent / "assets" |
10 | 11 |
|
@@ -44,12 +45,25 @@ def test_get(server: TSC.Server, user: TSC.UserItem) -> None: |
44 | 45 | assert len(user.favorites["projects"]) == 1 |
45 | 46 | assert len(user.favorites["datasources"]) == 1 |
46 | 47 |
|
47 | | - workbook = user.favorites["workbooks"][0] |
48 | | - print("favorited: ") |
49 | | - print(workbook) |
50 | | - view = user.favorites["views"][0] |
51 | | - datasource = user.favorites["datasources"][0] |
52 | | - project = user.favorites["projects"][0] |
| 48 | + collection = self.user.favorites["collections"][0] |
| 49 | + |
| 50 | + assert collection.id == "8c57cb8a-d65f-4a32-813e-5a3f86e8f94e" |
| 51 | + assert collection.name == "sample collection" |
| 52 | + assert collection.description == "description for sample collection" |
| 53 | + assert collection.total_item_count == 3 |
| 54 | + assert collection.permissioned_item_count == 2 |
| 55 | + assert collection.visibility == "Private" |
| 56 | + assert collection.created_at == parse_datetime("2016-08-11T21:22:40Z") |
| 57 | + assert collection.updated_at == parse_datetime("2016-08-11T21:34:17Z") |
| 58 | + |
| 59 | + def test_add_favorite_workbook(self) -> None: |
| 60 | + response_xml = read_xml_asset(ADD_FAVORITE_WORKBOOK_XML) |
| 61 | + workbook = TSC.WorkbookItem("") |
| 62 | + workbook._id = "6d13b0ca-043d-4d42-8c9d-3f3313ea3a00" |
| 63 | + workbook.name = "Superstore" |
| 64 | + with requests_mock.mock() as m: |
| 65 | + m.put(f"{self.baseurl}/{self.user.id}", text=response_xml) |
| 66 | + self.server.favorites.add_favorite_workbook(self.user, workbook) |
53 | 67 |
|
54 | 68 | assert workbook.id == "6d13b0ca-043d-4d42-8c9d-3f3313ea3a00" |
55 | 69 | assert view.id == "d79634e1-6063-4ec9-95ff-50acbf609ff5" |
|
0 commit comments