Skip to content

Commit a923768

Browse files
committed
update missed assertions
1 parent 30c4a3f commit a923768

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

tests/contrib/pylons/test_pylons.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_success_200(self, query_string=''):
174174

175175
assert span.service == 'web'
176176
assert span.resource == 'root.index'
177-
assert span.metrics.get(http.STATUS_CODE) == 200
177+
assert_span_http_status_code(span, 200)
178178
if config.pylons.trace_query_string:
179179
assert span.meta.get(http.QUERY_STRING) == query_string
180180
else:
@@ -264,7 +264,7 @@ def test_template_render(self):
264264

265265
assert request.service == 'web'
266266
assert request.resource == 'root.render'
267-
assert request.metrics.get(http.STATUS_CODE) == 200
267+
assert_span_http_status_code(request, 200)
268268
assert request.error == 0
269269

270270
assert template.service == 'web'
@@ -284,7 +284,7 @@ def test_template_render_exception(self):
284284

285285
assert request.service == 'web'
286286
assert request.resource == 'root.render_exception'
287-
assert request.metrics.get(http.STATUS_CODE) == 500
287+
assert_span_http_status_code(request, 500)
288288
assert request.error == 1
289289

290290
assert template.service == 'web'
@@ -424,6 +424,6 @@ def test_success_200_ot(self):
424424

425425
assert dd_span.service == 'web'
426426
assert dd_span.resource == 'root.index'
427-
assert dd_span.metrics.get(http.STATUS_CODE) == 200
427+
assert_span_http_status_code(dd_span, 200)
428428
assert dd_span.meta.get(http.URL) == 'http://localhost:80/'
429429
assert dd_span.error == 0

tests/contrib/pyramid/utils.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from ...opentracer.utils import init_tracer
1616
from ...base import BaseTracerTestCase
17+
from ...utils import assert_span_http_status_code
1718

1819

1920
class PyramidBase(BaseTracerTestCase):
@@ -65,7 +66,7 @@ def test_200(self, query_string=''):
6566
assert s.error == 0
6667
assert s.span_type == 'web'
6768
assert s.meta.get('http.method') == 'GET'
68-
assert s.metrics.get('http.status_code') == 200
69+
assert_span_http_status_code(s, 200)
6970
assert s.meta.get(http.URL) == 'http://localhost/'
7071
if config.pyramid.trace_query_string:
7172
assert s.meta.get(http.QUERY_STRING) == query_string
@@ -154,7 +155,7 @@ def test_404(self):
154155
assert s.error == 0
155156
assert s.span_type == 'web'
156157
assert s.meta.get('http.method') == 'GET'
157-
assert s.metrics.get('http.status_code') == 404
158+
assert_span_http_status_code(s, 404)
158159
assert s.meta.get(http.URL) == 'http://localhost/404'
159160

160161
def test_302(self):
@@ -169,7 +170,7 @@ def test_302(self):
169170
assert s.error == 0
170171
assert s.span_type == 'web'
171172
assert s.meta.get('http.method') == 'GET'
172-
assert s.metrics.get('http.status_code') == 302
173+
assert_span_http_status_code(s, 302)
173174
assert s.meta.get(http.URL) == 'http://localhost/redirect'
174175

175176
def test_204(self):
@@ -184,7 +185,7 @@ def test_204(self):
184185
assert s.error == 0
185186
assert s.span_type == 'web'
186187
assert s.meta.get('http.method') == 'GET'
187-
assert s.metrics.get('http.status_code') == 204
188+
assert_span_http_status_code(s, 204)
188189
assert s.meta.get(http.URL) == 'http://localhost/nocontent'
189190

190191
def test_exception(self):
@@ -202,7 +203,7 @@ def test_exception(self):
202203
assert s.error == 1
203204
assert s.span_type == 'web'
204205
assert s.meta.get('http.method') == 'GET'
205-
assert s.metrics.get('http.status_code') == 500
206+
assert_span_http_status_code(s, 500)
206207
assert s.meta.get(http.URL) == 'http://localhost/exception'
207208
assert s.meta.get('pyramid.route.name') == 'exception'
208209

@@ -218,7 +219,7 @@ def test_500(self):
218219
assert s.error == 1
219220
assert s.span_type == 'web'
220221
assert s.meta.get('http.method') == 'GET'
221-
assert s.metrics.get('http.status_code') == 500
222+
assert_span_http_status_code(s, 500)
222223
assert s.meta.get(http.URL) == 'http://localhost/error'
223224
assert s.meta.get('pyramid.route.name') == 'error'
224225
assert type(s.error) == int
@@ -238,7 +239,7 @@ def test_json(self):
238239
assert s.error == 0
239240
assert s.span_type == 'web'
240241
assert s.meta.get('http.method') == 'GET'
241-
assert s.metrics.get('http.status_code') == 200
242+
assert_span_http_status_code(s, 200)
242243
assert s.meta.get(http.URL) == 'http://localhost/json'
243244
assert s.meta.get('pyramid.route.name') == 'json'
244245

@@ -262,7 +263,7 @@ def test_renderer(self):
262263
assert s.error == 0
263264
assert s.span_type == 'web'
264265
assert s.meta.get('http.method') == 'GET'
265-
assert s.metrics.get('http.status_code') == 200
266+
assert_span_http_status_code(s, 200)
266267
assert s.meta.get(http.URL) == 'http://localhost/renderer'
267268
assert s.meta.get('pyramid.route.name') == 'renderer'
268269

@@ -284,7 +285,7 @@ def test_http_exception_response(self):
284285
assert s.error == 1
285286
assert s.span_type == 'web'
286287
assert s.meta.get('http.method') == 'GET'
287-
assert s.metrics.get('http.status_code') == 404
288+
assert_span_http_status_code(s, 404)
288289
assert s.meta.get(http.URL) == 'http://localhost/404/raise_exception'
289290

290291
def test_insert_tween_if_needed_already_set(self):
@@ -356,6 +357,6 @@ def test_200_ot(self):
356357
assert dd_span.error == 0
357358
assert dd_span.span_type == 'web'
358359
assert dd_span.meta.get('http.method') == 'GET'
359-
assert dd_span.metrics.get('http.status_code') == 200
360+
assert_span_http_status_code(dd_span, 200)
360361
assert dd_span.meta.get(http.URL) == 'http://localhost/'
361362
assert dd_span.meta.get('pyramid.route.name') == 'index'

0 commit comments

Comments
 (0)