0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/ee/clickhouse/models/test/test_action.py
Tim Glaser 80d20e385b
Clickhouse use elements chain (#1849)
* Clickhouse use elements chain

* Fix stuff

* Add action tests and start regex

* Progress

* Progress part deux

* Fix everything

* Add tag name filtering

* Fix funnels

* Fix tag name regex

* Fix ordering

* Fix type issues

* Fix empty nth-child

* Remove commented code

* Split with semicolon and escaped quotes

* Specify all select columns
2020-10-16 14:07:03 +02:00

41 lines
1.1 KiB
Python

from typing import List
from uuid import uuid4
from ee.clickhouse.models.action import query_action
from ee.clickhouse.models.event import create_event
from ee.clickhouse.util import ClickhouseTestMixin
from posthog.models.action import Action
from posthog.models.event import Event
from posthog.models.person import Person
from posthog.test.test_event_model import filter_by_actions_factory
def _create_event(**kwargs) -> Event:
pk = uuid4()
kwargs.update({"event_uuid": pk})
create_event(**kwargs)
return Event(pk=str(pk))
def _get_events_for_action(action: Action) -> List[Event]:
events = query_action(action)
ret = []
if not events:
return []
for event in events:
ev = Event(pk=str(event[0]))
ev.distinct_id = event[5]
ret.append(ev)
return ret
def _create_person(**kwargs) -> Person:
person = Person.objects.create(**kwargs)
return Person(id=person.uuid)
class TestActions(
ClickhouseTestMixin, filter_by_actions_factory(_create_event, _create_person, _get_events_for_action) # type: ignore
):
pass