Skip to content

Commit 1b06f10

Browse files
committed
format & update tests
1 parent 7b29b1b commit 1b06f10

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

backend/btrixcloud/crawlconfigs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,9 @@ async def get_crawl_configs(
14151415

14161416
@router.get("/tags", response_model=List[str], deprecated=True)
14171417
async def get_crawl_config_tags(org: Organization = Depends(org_viewer_dep)):
1418-
'''
1418+
"""
14191419
Deprecated - prefer /api/orgs/{oid}/crawlconfigs/tagCounts instead.
1420-
'''
1420+
"""
14211421
return await ops.get_crawl_config_tags(org)
14221422

14231423
@router.get("/tagCounts", response_model=CrawlConfigTags)

backend/btrixcloud/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ class CrawlConfigTagCount(BaseModel):
584584
tag: str
585585
count: int
586586

587+
587588
# ============================================================================
588589
class CrawlConfigTags(BaseModel):
589590
"""Response model for crawlconfig tags"""

backend/test/test_crawl_config_tags.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ def test_get_config_by_tag_1(admin_auth_headers, default_org_id):
5050
assert sorted(data) == ["tag-1", "tag-2", "wr-test-1", "wr-test-2"]
5151

5252

53+
def test_get_config_by_tag_counts_1(admin_auth_headers, default_org_id):
54+
r = requests.get(
55+
f"{API_PREFIX}/orgs/{default_org_id}/crawlconfigs/tagCounts",
56+
headers=admin_auth_headers,
57+
)
58+
data = r.json()
59+
assert data == {
60+
"tags": [
61+
{"tag": "tag-1", "count": 1},
62+
{"tag": "tag-2", "count": 1},
63+
{"tag": "wr-test-1", "count": 1},
64+
{"tag": "wr-test-2", "count": 1},
65+
]
66+
}
67+
68+
5369
def test_create_new_config_2(admin_auth_headers, default_org_id):
5470
r = requests.post(
5571
f"{API_PREFIX}/orgs/{default_org_id}/crawlconfigs/",
@@ -84,6 +100,24 @@ def test_get_config_by_tag_2(admin_auth_headers, default_org_id):
84100
]
85101

86102

103+
def test_get_config_by_tag_counts_2(admin_auth_headers, default_org_id):
104+
r = requests.get(
105+
f"{API_PREFIX}/orgs/{default_org_id}/crawlconfigs/tagCounts",
106+
headers=admin_auth_headers,
107+
)
108+
data = r.json()
109+
assert data == {
110+
"tags": [
111+
{"tag": "tag-0", "count": 1},
112+
{"tag": "tag-1", "count": 1},
113+
{"tag": "tag-2", "count": 1},
114+
{"tag": "tag-3", "count": 1},
115+
{"tag": "wr-test-1", "count": 1},
116+
{"tag": "wr-test-2", "count": 1},
117+
]
118+
}
119+
120+
87121
def test_get_config_2(admin_auth_headers, default_org_id):
88122
r = requests.get(
89123
f"{API_PREFIX}/orgs/{default_org_id}/crawlconfigs/{new_cid_2}",

0 commit comments

Comments
 (0)