Skip to content

Commit

Permalink
ensure errors when no type is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-sentry committed Jan 15, 2025
1 parent 5a432e1 commit 825e5fb
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,38 @@ def test_basic(self) -> None:
error.ParseFromString(response.data)
assert response.status_code == 200, (error.message, error.details)

def test_errors_without_type(self) -> None:
ts = Timestamp()
ts.GetCurrentTime()
tstart = Timestamp(seconds=ts.seconds - 3600)
message = TimeSeriesRequest(
meta=RequestMeta(
project_ids=[1, 2, 3],
organization_id=1,
cogs_category="something",
referrer="something",
start_timestamp=tstart,
end_timestamp=ts,
),
aggregations=[
AttributeAggregation(
aggregate=Function.FUNCTION_COUNT,
key=AttributeKey(
type=AttributeKey.TYPE_FLOAT, name="sentry.duration"
),
label="count",
),
],
granularity_secs=60,
)
response = self.app.post(
"/rpc/EndpointTimeSeries/v1", data=message.SerializeToString()
)
error = Error()
if response.status_code != 200:
error.ParseFromString(response.data)
assert response.status_code == 400, error

def test_sum(self) -> None:
# store a a test metric with a value of 1, every second of one hour
granularity_secs = 300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,43 @@ def test_basic(self) -> None:
error_proto.ParseFromString(response.data)
assert response.status_code == 200, error_proto

def test_errors_without_type(self) -> None:
ts = Timestamp()
ts.GetCurrentTime()
message = TraceItemTableRequest(
meta=RequestMeta(
project_ids=[1, 2, 3],
organization_id=1,
cogs_category="something",
referrer="something",
start_timestamp=ts,
end_timestamp=ts,
),
filter=TraceItemFilter(
exists_filter=ExistsFilter(
key=AttributeKey(type=AttributeKey.TYPE_STRING, name="color")
)
),
columns=[
Column(key=AttributeKey(type=AttributeKey.TYPE_STRING, name="location"))
],
order_by=[
TraceItemTableRequest.OrderBy(
column=Column(
key=AttributeKey(type=AttributeKey.TYPE_STRING, name="location")
)
)
],
limit=10,
)
response = self.app.post(
"/rpc/EndpointTraceItemTable/v1", data=message.SerializeToString()
)
error_proto = ErrorProto()
if response.status_code != 200:
error_proto.ParseFromString(response.data)
assert response.status_code == 400, error_proto

def test_with_data(self, setup_teardown: Any) -> None:
ts = Timestamp(seconds=int(BASE_TIME.timestamp()))
hour_ago = int((BASE_TIME - timedelta(hours=1)).timestamp())
Expand Down

0 comments on commit 825e5fb

Please sign in to comment.