Skip to content

Commit

Permalink
fix(misc): remove variable allocation when not needed (part #2) (#10502)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidoiaquinti authored Jun 27, 2022
1 parent 7b1b6b8 commit 698baf6
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 317 deletions.
1 change: 0 additions & 1 deletion ee/api/test/test_dashboard_collaborators.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def test_cannot_update_existing_collaborator(self):
f"/api/projects/{self.test_dashboard.team_id}/dashboards/{self.test_dashboard.id}/collaborators/{other_user.uuid}",
{"level": Dashboard.PrivilegeLevel.CAN_VIEW,},
)
response_data = response.json()

self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

Expand Down
4 changes: 2 additions & 2 deletions ee/clickhouse/models/test/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def test_double(self):
)

action1 = Action.objects.create(team=self.team, name="action1")
step1 = ActionStep.objects.create(
ActionStep.objects.create(
event="insight viewed",
action=action1,
properties=[{"key": "insight", "type": "event", "value": ["RETENTION"], "operator": "exact"}],
)
step2 = ActionStep.objects.create(
ActionStep.objects.create(
event="insight viewed",
action=action1,
properties=[{"key": "filters_count", "type": "event", "value": "1", "operator": "gt"}],
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/queries/funnels/test/test_funnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_funnel_aggregation_with_groups_with_cohort_filtering(self):
},
],
}
created_people = journeys_for(events_by_person, self.team)
journeys_for(events_by_person, self.team)
cohort.calculate_people_ch(pending_version=0)

filters = {
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/queries/test/test_column_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_should_query_element_chain_column(self):

def test_should_query_element_chain_column_with_actions(self):
action = Action.objects.create(team=self.team)
step1 = ActionStep.objects.create(
ActionStep.objects.create(
event="$autocapture", action=action, url="https://example.com/donate", url_matching=ActionStep.EXACT,
)

Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/queries/test/test_trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_breakdown_by_group_props(self):
],
}

people = journeys_for(events_by_person=journey, team=self.team)
journeys_for(events_by_person=journey, team=self.team)

filter = Filter(
data={
Expand Down
2 changes: 1 addition & 1 deletion ee/clickhouse/views/test/test_clickhouse_stickiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_aggregate_by_groups(self):
@snapshot_clickhouse_queries
@patch("posthoganalytics.feature_enabled", return_value=True)
def test_timezones(self, patch_feature_enabled):
people = journeys_for(
journeys_for(
{
"person1": [
{
Expand Down
16 changes: 7 additions & 9 deletions posthog/models/test/test_event_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_filter_events_by_url(self):
event="$autocapture", action=action4, url="/123$", url_matching=ActionStep.REGEX,
)

event1_uuid = _create_event(team=self.team, distinct_id="whatever", event="$autocapture")
_create_event(team=self.team, distinct_id="whatever", event="$autocapture")
event2_uuid = _create_event(
event="$autocapture",
team=self.team,
Expand Down Expand Up @@ -314,8 +314,8 @@ def test_person_with_different_distinct_id(self):
action_watch_movie = Action.objects.create(team=self.team, name="watched movie")
ActionStep.objects.create(action=action_watch_movie, tag_name="a", href="/movie", event="$autocapture")

person = _create_person(distinct_ids=["anonymous_user", "is_now_signed_up"], team=self.team)
event_watched_movie_anonymous_uuid = _create_event(
_create_person(distinct_ids=["anonymous_user", "is_now_signed_up"], team=self.team)
_create_event(
distinct_id="anonymous_user",
team=self.team,
elements=[Element(tag_name="a", href="/movie")],
Expand All @@ -337,13 +337,11 @@ def test_no_person_leakage_from_other_teams(self):
action_watch_movie = Action.objects.create(team=self.team, name="watched movie")
ActionStep.objects.create(action=action_watch_movie, event="user signed up")

person = _create_person(distinct_ids=["anonymous_user"], team=self.team)
event_watched_movie_anonymous = _create_event(
event="user signed up", distinct_id="anonymous_user", team=self.team
)
_create_person(distinct_ids=["anonymous_user"], team=self.team)
_create_event(event="user signed up", distinct_id="anonymous_user", team=self.team)

team2 = Organization.objects.bootstrap(None)[2]
person2 = _create_person(distinct_ids=["anonymous_user2"], team=team2)
_create_person(distinct_ids=["anonymous_user2"], team=team2)

events = _get_events_for_action(action_watch_movie)
self.assertEqual(len(events), 1)
Expand All @@ -363,7 +361,7 @@ def test_person_property(self):

def test_no_steps(self):
_create_person(distinct_ids=["whatever"], team=self.team)
event1 = _create_event(
_create_event(
event="$autocapture",
team=self.team,
distinct_id="whatever",
Expand Down
2 changes: 1 addition & 1 deletion posthog/models/test/test_user_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_analytics_metadata(self):
self.team.completed_snippet_onboarding = True
self.team.ingested_event = True
self.team.save()
team_2: Team = Team.objects.create(organization=self.organization)
Team.objects.create(organization=self.organization)
user_2: User = User.objects.create(email="test_org_2@posthog.com", email_opt_in=True)
user_2.join(organization=self.organization)

Expand Down
Loading

0 comments on commit 698baf6

Please sign in to comment.