MCPcopy
hub / github.com/PostHog/posthog / test_paths_start

Method test_paths_start

posthog/queries/test/test_paths.py:358–434  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

356 self.assertEqual(response[2]["value"], 1)
357
358 def test_paths_start(self):
359 _create_person(team_id=self.team.pk, distinct_ids=["person_1"])
360 _create_person(team_id=self.team.pk, distinct_ids=["person_2"])
361 _create_person(team_id=self.team.pk, distinct_ids=["person_3"])
362 _create_person(team_id=self.team.pk, distinct_ids=["person_4"])
363 _create_person(team_id=self.team.pk, distinct_ids=["person_5a", "person_5b"])
364
365 _create_event(properties={"$current_url": "/"}, distinct_id="person_1", event="$pageview", team=self.team),
366 _create_event(
367 properties={"$current_url": "/about/"}, distinct_id="person_1", event="$pageview", team=self.team
368 ),
369 _create_event(properties={"$current_url": "/"}, distinct_id="person_2", event="$pageview", team=self.team),
370 _create_event(
371 properties={"$current_url": "/pricing/"}, distinct_id="person_2", event="$pageview", team=self.team
372 ),
373 _create_event(
374 properties={"$current_url": "/about"}, distinct_id="person_2", event="$pageview", team=self.team
375 ),
376 _create_event(
377 properties={"$current_url": "/pricing"}, distinct_id="person_3", event="$pageview", team=self.team
378 ),
379 _create_event(properties={"$current_url": "/"}, distinct_id="person_3", event="$pageview", team=self.team),
380 _create_event(
381 properties={"$current_url": "/about/"}, distinct_id="person_3", event="$pageview", team=self.team
382 ),
383 _create_event(properties={"$current_url": "/"}, distinct_id="person_4", event="$pageview", team=self.team),
384 _create_event(
385 properties={"$current_url": "/pricing/"}, distinct_id="person_4", event="$pageview", team=self.team
386 ),
387 _create_event(
388 properties={"$current_url": "/pricing"}, distinct_id="person_5a", event="$pageview", team=self.team
389 ),
390 _create_event(
391 properties={"$current_url": "/about"}, distinct_id="person_5b", event="$pageview", team=self.team
392 ),
393 _create_event(
394 properties={"$current_url": "/pricing/"}, distinct_id="person_5a", event="$pageview", team=self.team
395 ),
396 _create_event(
397 properties={"$current_url": "/help"}, distinct_id="person_5b", event="$pageview", team=self.team
398 ),
399
400 response = self.client.get(
401 f"/api/projects/{self.team.id}/insights/path/?type=%24pageview&start=%2Fpricing"
402 ).json()
403
404 filter = PathFilter(data={"path_type": "$pageview", "start_point": "/pricing"})
405 response = paths(team=self.team, filter=filter).run(team=self.team, filter=filter)
406
407 self.assertEqual(len(response), 5)
408
409 self.assertTrue(response[0].items() >= {"source": "1_/pricing", "target": "2_/about", "value": 2}.items())
410 self.assertTrue(response[1].items() >= {"source": "1_/pricing", "target": "2_/", "value": 1}.items())
411 self.assertTrue(response[2].items() >= {"source": "2_/", "target": "3_/about", "value": 1}.items())
412 self.assertTrue(response[3].items() >= {"source": "2_/about", "target": "3_/pricing", "value": 1}.items())
413 self.assertTrue(response[4].items() >= {"source": "3_/pricing", "target": "4_/help", "value": 1}.items())
414
415 # ensure trailing slashes make no difference

Callers

nothing calls this directly

Calls 6

_create_personFunction · 0.90
_create_eventFunction · 0.90
PathFilterClass · 0.90
jsonMethod · 0.80
getMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected