Skip to content

Commit 042e5ce

Browse files
committed
add back test
1 parent 33cf1a6 commit 042e5ce

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

backend/test/test_profiles.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,62 @@ def profile_id(admin_auth_headers, default_org_id, profile_browser_id):
107107
time.sleep(5)
108108

109109

110+
@pytest.fixture(scope="module")
111+
def profile_config_id(admin_auth_headers, default_org_id, profile_id):
112+
r = requests.get(
113+
f"{API_PREFIX}/orgs/{default_org_id}/profiles/{profile_id}",
114+
headers=admin_auth_headers,
115+
)
116+
assert r.status_code == 200
117+
data = r.json()
118+
assert data["id"] == profile_id
119+
assert data["name"] == PROFILE_NAME
120+
assert data["description"] == PROFILE_DESC
121+
assert data["userid"]
122+
assert data["oid"] == default_org_id
123+
assert data.get("origins") or data.get("origins") == []
124+
assert data["createdBy"]
125+
assert data["createdByName"] == "admin"
126+
assert data["modifiedBy"]
127+
assert data["modifiedByName"] == "admin"
128+
assert not data["baseid"]
129+
130+
created = data["created"]
131+
assert created
132+
assert created.endswith("Z")
133+
134+
modified = data["modified"]
135+
assert modified
136+
assert modified.endswith("Z")
137+
138+
resource = data["resource"]
139+
assert resource
140+
assert resource["filename"]
141+
assert resource["hash"]
142+
assert resource["size"]
143+
assert resource["storage"]
144+
assert resource["storage"]["name"]
145+
assert resource.get("replicas") or resource.get("replicas") == []
146+
147+
# Use profile in a workflow
148+
r = requests.post(
149+
f"{API_PREFIX}/orgs/{default_org_id}/crawlconfigs/",
150+
headers=admin_auth_headers,
151+
json={
152+
"runNow": False,
153+
"name": "Profile Test Crawl",
154+
"description": "Crawl using browser profile",
155+
"config": {
156+
"seeds": [{"url": "https://webrecorder.net/"}],
157+
"exclude": "community",
158+
},
159+
"profileid": profile_id,
160+
},
161+
)
162+
data = r.json()
163+
return data["id"]
164+
165+
110166
@pytest.fixture(scope="module")
111167
def profile_2_id(admin_auth_headers, default_org_id, profile_browser_2_id):
112168
prepare_browser_for_profile_commit(
@@ -146,9 +202,10 @@ def test_commit_browser_to_new_profile(admin_auth_headers, default_org_id, profi
146202
assert profile_id
147203

148204

149-
def test_get_profile(admin_auth_headers, default_org_id, profile_id):
205+
def test_get_profile(admin_auth_headers, default_org_id, profile_id, profile_config_id):
150206
start_time = time.monotonic()
151207
time_limit = 10
208+
# Check get endpoint again and check that inUse is updated
152209
while True:
153210
try:
154211
r = requests.get(
@@ -181,6 +238,7 @@ def test_get_profile(admin_auth_headers, default_org_id, profile_id):
181238
assert resource.get("replicas") or resource.get("replicas") == []
182239

183240
assert "crawlconfigs" not in data
241+
assert data["inUse"] == True
184242
break
185243
except:
186244
if time.monotonic() - start_time > time_limit:

0 commit comments

Comments
 (0)