From 6cb781770b8e75dc7b3809d3dcbe4de6f7598461 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 3 Oct 2023 13:58:56 +0100 Subject: [PATCH] update tests --- .../test/notebooks/test_notebook_filtering.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/posthog/api/test/notebooks/test_notebook_filtering.py b/posthog/api/test/notebooks/test_notebook_filtering.py index 5f634de548fc7..6cee9ac19d954 100644 --- a/posthog/api/test/notebooks/test_notebook_filtering.py +++ b/posthog/api/test/notebooks/test_notebook_filtering.py @@ -35,10 +35,13 @@ ], } -INSIGHT_COMMENT = lambda id: { - "type": "ph-insight", +QUERY_CONTENT = lambda id: { + "type": "ph-query", "attrs": { - "id": id or "insight_short_id", + "query": { + "kind": "SavedInsightNode", + "shortId": id or "insight_short_id", + } }, } @@ -133,7 +136,7 @@ def test_filters_based_on_params(self) -> None: def test_filtering_by_types(self) -> None: playlist_content_notebook = self._create_notebook_with_content([PLAYLIST_CONTENT()]) - insight_content_notebook = self._create_notebook_with_content([INSIGHT_COMMENT("insight_id")]) + insight_content_notebook = self._create_notebook_with_content([QUERY_CONTENT("insight_id")]) feature_flag_content_notebook = self._create_notebook_with_content([FEATURE_FLAG_CONTENT("feature_flag_id")]) person_content_notebook = self._create_notebook_with_content([PERSON_CONTENT("person_id")]) recording_comment_notebook = self._create_notebook_with_content( @@ -146,7 +149,7 @@ def test_filtering_by_types(self) -> None: assert len(no_filter_response.json()["results"]) == 6 # filter by insight - insight_filter_response = self.client.get(f"/api/projects/{self.team.id}/notebooks?contains=insight:true") + insight_filter_response = self.client.get(f"/api/projects/{self.team.id}/notebooks?contains=query:true") assert [n["id"] for n in insight_filter_response.json()["results"]] == [insight_content_notebook] # filter by playlist @@ -177,7 +180,7 @@ def test_filtering_by_types(self) -> None: def test_filtering_by_abscence_of_types(self) -> None: playlist_content_notebook = self._create_notebook_with_content([PLAYLIST_CONTENT()]) - insight_content_notebook = self._create_notebook_with_content([INSIGHT_COMMENT("insight_id")]) + insight_content_notebook = self._create_notebook_with_content([QUERY_CONTENT("insight_id")]) feature_flag_content_notebook = self._create_notebook_with_content([FEATURE_FLAG_CONTENT("feature_flag_id")]) person_content_notebook = self._create_notebook_with_content([PERSON_CONTENT("person_id")]) recording_comment_notebook = self._create_notebook_with_content( @@ -190,7 +193,7 @@ def test_filtering_by_abscence_of_types(self) -> None: assert len(no_filter_response.json()["results"]) == 6 # filter by insight - insight_filter_response = self.client.get(f"/api/projects/{self.team.id}/notebooks?contains=insight:false") + insight_filter_response = self.client.get(f"/api/projects/{self.team.id}/notebooks?contains=query:false") assert sorted([n["id"] for n in insight_filter_response.json()["results"]]) == sorted( [ playlist_content_notebook, @@ -267,9 +270,9 @@ def test_filtering_by_abscence_of_types(self) -> None: ] ) - @parameterized.expand([["insight"], ["insights"]]) + @parameterized.expand([["query"], ["queries"]]) def test_filtering_by_just_the_target_name_is_truthy(self, target_name: str) -> None: - insight_content_notebook_one = self._create_notebook_with_content([INSIGHT_COMMENT("insight_id_one")]) + insight_content_notebook_one = self._create_notebook_with_content([QUERY_CONTENT("insight_id_one")]) _feature_flag_content_notebook_one = self._create_notebook_with_content( [FEATURE_FLAG_CONTENT("feature_flag_id_one")] ) @@ -283,8 +286,8 @@ def test_filtering_by_just_the_target_name_is_truthy(self, target_name: str) -> def test_filtering_by_id_of_types(self) -> None: self._create_notebook_with_content([PLAYLIST_CONTENT()]) - insight_content_notebook_one = self._create_notebook_with_content([INSIGHT_COMMENT("insight_id_one")]) - _insight_content_notebook_two = self._create_notebook_with_content([INSIGHT_COMMENT("insight_id_two")]) + insight_content_notebook_one = self._create_notebook_with_content([QUERY_CONTENT("insight_id_one")]) + _insight_content_notebook_two = self._create_notebook_with_content([QUERY_CONTENT("insight_id_two")]) feature_flag_content_notebook_one = self._create_notebook_with_content( [FEATURE_FLAG_CONTENT("feature_flag_id_one")] @@ -316,7 +319,7 @@ def test_filtering_by_id_of_types(self) -> None: # filter by insight insight_filter_response = self.client.get( - f"/api/projects/{self.team.id}/notebooks?contains=insight:insight_id_one" + f"/api/projects/{self.team.id}/notebooks?contains=query:insight_id_one" ) assert sorted([n["id"] for n in insight_filter_response.json()["results"]]) == sorted( [