Пример #1
0
    def test_outcomes_dataset_with_org_id(self):
        query_params = SnubaQueryParams(
            dataset=Dataset.Outcomes,
            filter_keys={"org_id": [self.organization.id]})

        kwargs, _, _ = _prepare_query_params(query_params)
        assert kwargs["organization"] == self.organization.id
Пример #2
0
    def test_transactions_dataset_with_project_id(self):
        query_params = SnubaQueryParams(
            dataset=Dataset.Transactions,
            filter_keys={"project_id": [self.project.id]})

        kwargs, _, _ = _prepare_query_params(query_params)
        assert kwargs["project"] == [self.project.id]
Пример #3
0
    def test_outcomes_dataset_with_key_id(self):
        key = self.create_project_key(project=self.project)
        query_params = SnubaQueryParams(dataset=Dataset.Outcomes,
                                        filter_keys={"key_id": [key.id]})

        kwargs, _, _ = _prepare_query_params(query_params)
        assert kwargs["organization"] == self.organization.id
Пример #4
0
 def test_original_query_params_does_not_get_mutated(self):
     snuba_params = SnubaQueryParams(
         dataset=Dataset.Sessions,
         start=datetime.now() - timedelta(hours=1),
         end=datetime.now(),
         groupby=[],
         conditions=[[["environment", "IN", {"development", "abc"}]]],
         filter_keys={"release": [self.create_release(version="1.0.0").id]},
         aggregations=[],
         rollup=86400,
         is_grouprelease=False,
         **{"selected_columns": ["sessions"]},
     )
     conditions = [[["environment", "IN", {"development", "abc"}]]]
     kwargs = {"selected_columns": ["sessions"]}
     _prepare_query_params(snuba_params)
     assert conditions == snuba_params.conditions
     assert kwargs == snuba_params.kwargs
Пример #5
0
    def test_invalid_dataset_provided(self):
        query_params = SnubaQueryParams(dataset="invalid_dataset")

        with pytest.raises(UnqualifiedQueryError):
            _prepare_query_params(query_params)
Пример #6
0
    def test_outcomes_dataset_with_no_org_id_given(self):
        query_params = SnubaQueryParams(dataset=Dataset.Outcomes)

        with pytest.raises(UnqualifiedQueryError):
            _prepare_query_params(query_params)