|
1 | | -from typing import TYPE_CHECKING |
2 | | - |
3 | 1 | from posit import connect |
4 | 2 |
|
5 | | -if TYPE_CHECKING: |
6 | | - from posit.connect.content import ContentItem |
7 | | - |
8 | 3 |
|
9 | | -# add integration tests here! |
10 | 4 | class TestTags: |
11 | 5 | @classmethod |
12 | 6 | def setup_class(cls): |
@@ -146,20 +140,22 @@ def test_tag_content_items(self): |
146 | 140 | assert len(tagC.content_items.find()) == 3 |
147 | 141 |
|
148 | 142 | # Make sure unique content items are found |
149 | | - content_items_list: list[ContentItem] = [] |
150 | | - for tag in [tagA, *tagA.descendant_tags.find()]: |
151 | | - content_items_list.extend(tag.content_items.find()) |
152 | | - # Get unique content_item guids |
153 | | - content_item_guids = set[str]() |
154 | | - for content_item in content_items_list: |
155 | | - if content_item["guid"] not in content_item_guids: |
156 | | - content_item_guids.add(content_item["guid"]) |
157 | | - |
158 | | - assert content_item_guids == { |
| 143 | + child_content_items = tagA.child_tags.content_items.find() |
| 144 | + assert len(child_content_items) == 2 |
| 145 | + child_content_item_guids = [content_item["guid"] for content_item in child_content_items] |
| 146 | + assert child_content_item_guids == [self.contentB["guid"], self.contentC["guid"]] |
| 147 | + |
| 148 | + descendant_content_items = tagA.descendant_tags.content_items.find() |
| 149 | + assert len(descendant_content_items) == 3 |
| 150 | + |
| 151 | + descendant_content_item_guids = [ |
| 152 | + content_item["guid"] for content_item in descendant_content_items |
| 153 | + ] |
| 154 | + assert descendant_content_item_guids == [ |
159 | 155 | self.contentA["guid"], |
160 | 156 | self.contentB["guid"], |
161 | 157 | self.contentC["guid"], |
162 | | - } |
| 158 | + ] |
163 | 159 |
|
164 | 160 | self.contentA.tags.delete(tagRoot) |
165 | 161 | self.contentB.tags.delete(tagRoot) |
|
0 commit comments