forked from instana/python-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_helpers.py
More file actions
87 lines (64 loc) · 2.62 KB
/
Copy pathtest_helpers.py
File metadata and controls
87 lines (64 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from nose.tools import assert_equals
from instana.helpers import eum_snippet, eum_test_snippet
# fake trace_id to test against
trace_id = "aMLx9G2GnnQ6QyMCLJLuCM8nw"
# fake api key to test against
eum_api_key = "FJB66VjwGgGQX6jiCpekoR4vf"
# fake meta key/values
meta1 = "Z7RmMKQAiyCLEAmseNy7e6Vm4"
meta2 = "Dp2bowfm6kJVD9CccmyBt4ePD"
meta3 = "N4poUwbNz98YcvWRAizy2phCo"
def test_vanilla_eum_snippet():
eum_string = eum_snippet(trace_id=trace_id, eum_api_key=eum_api_key)
assert type(eum_string) is str
assert eum_string.find(trace_id) != -1
assert eum_string.find(eum_api_key) != -1
def test_eum_snippet_with_meta():
meta_kvs = {}
meta_kvs['meta1'] = meta1
meta_kvs['meta2'] = meta2
meta_kvs['meta3'] = meta3
eum_string = eum_snippet(trace_id=trace_id, eum_api_key=eum_api_key, meta=meta_kvs)
assert type(eum_string) is str
assert eum_string.find(trace_id) != -1
assert eum_string.find(eum_api_key) != -1
assert eum_string.find(meta1) != -1
assert eum_string.find(meta2) != -1
assert eum_string.find(meta3) != -1
def test_eum_snippet_error():
meta_kvs = {}
meta_kvs['meta1'] = meta1
meta_kvs['meta2'] = meta2
meta_kvs['meta3'] = meta3
# No active span on tracer & no trace_id passed in.
eum_string = eum_snippet(eum_api_key=eum_api_key, meta=meta_kvs)
assert_equals('', eum_string)
def test_vanilla_eum_test_snippet():
eum_string = eum_test_snippet(trace_id=trace_id, eum_api_key=eum_api_key)
assert type(eum_string) is str
assert eum_string.find(trace_id) != -1
assert eum_string.find(eum_api_key) != -1
assert eum_string.find('reportingUrl') != -1
assert eum_string.find('//eum-test-fullstack-0-us-west-2.instana.io') != -1
def test_eum_test_snippet_with_meta():
meta_kvs = {}
meta_kvs['meta1'] = meta1
meta_kvs['meta2'] = meta2
meta_kvs['meta3'] = meta3
eum_string = eum_test_snippet(trace_id=trace_id, eum_api_key=eum_api_key, meta=meta_kvs)
assert type(eum_string) is str
assert eum_string.find('reportingUrl') != -1
assert eum_string.find('//eum-test-fullstack-0-us-west-2.instana.io') != -1
assert eum_string.find(trace_id) != -1
assert eum_string.find(eum_api_key) != -1
assert eum_string.find(meta1) != -1
assert eum_string.find(meta2) != -1
assert eum_string.find(meta3) != -1
def test_eum_test_snippet_error():
meta_kvs = {}
meta_kvs['meta1'] = meta1
meta_kvs['meta2'] = meta2
meta_kvs['meta3'] = meta3
# No active span on tracer & no trace_id passed in.
eum_string = eum_test_snippet(eum_api_key=eum_api_key, meta=meta_kvs)
assert_equals('', eum_string)