|
16 | 16 | from sentry.search.events.builder import QueryBuilder
|
17 | 17 | from sentry.search.events.types import ParamsType, QueryBuilderConfig
|
18 | 18 | from sentry.snuba.dataset import Dataset
|
| 19 | +from sentry.snuba.referrer import Referrer |
19 | 20 | from sentry.testutils.cases import TestCase
|
20 |
| -from sentry.utils.snuba import QueryOutsideRetentionError |
| 21 | +from sentry.utils.snuba import QueryOutsideRetentionError, UnqualifiedQueryError, bulk_snuba_queries |
21 | 22 | from sentry.utils.validators import INVALID_ID_DETAILS
|
22 | 23 |
|
23 | 24 | pytestmark = pytest.mark.sentry_metrics
|
@@ -67,6 +68,27 @@ def test_simple_query(self):
|
67 | 68 | )
|
68 | 69 | query.get_snql_query().validate()
|
69 | 70 |
|
| 71 | + def test_query_without_project_ids(self): |
| 72 | + params = { |
| 73 | + "start": self.params["start"], |
| 74 | + "end": self.params["end"], |
| 75 | + "organization_id": self.organization.id, |
| 76 | + } |
| 77 | + with pytest.raises(UnqualifiedQueryError): |
| 78 | + query = QueryBuilder(Dataset.Discover, params, query="foo", selected_columns=["id"]) |
| 79 | + bulk_snuba_queries([query.get_snql_query()], referrer=Referrer.TESTING_TEST.value) |
| 80 | + |
| 81 | + def test_query_with_empty_project_ids(self): |
| 82 | + params = { |
| 83 | + "start": self.params["start"], |
| 84 | + "end": self.params["end"], |
| 85 | + "project_id": [], # We add an empty project_id list |
| 86 | + "organization_id": self.organization.id, |
| 87 | + } |
| 88 | + with pytest.raises(UnqualifiedQueryError): |
| 89 | + query = QueryBuilder(Dataset.Discover, params, query="foo", selected_columns=["id"]) |
| 90 | + bulk_snuba_queries([query.get_snql_query()], referrer=Referrer.TESTING_TEST.value) |
| 91 | + |
70 | 92 | def test_simple_orderby(self):
|
71 | 93 | query = QueryBuilder(
|
72 | 94 | Dataset.Discover,
|
|
0 commit comments