-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.yaml
81 lines (77 loc) · 2.21 KB
/
test.yaml
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
###############################################################################
# Integration test for rp-connect-python.
#
# Exercises as much surface area as possible to find regressions.
#
###############################################################################
http:
enabled: false
input:
stdin: {}
output:
stdout: {}
pipeline:
processors:
- python:
mode: isolated
script: |
# Return a lowercase version.
msg = content().decode()
root = msg.lower()
# Set a metadata value.
meta["key"] = "a string value"
- python:
mode: isolated_legacy
script: |
# Filter to just A-Za-z.
msg = content().decode()
root = "".join([c for c in msg if c.isalpha()])
# Set a complex metadata value and read existing metadata.
meta["complex"] = {"name": "Dave", "key": metadata("key")}
- python:
mode: global
script: |
# Compute letter frequency and report most common.
letters = content().decode()
freq = {}
for c in letters:
freq.update({c: freq.get(c, 0) + 1})
root.frequency = freq
root.max = 0
root.most = []
for k, v in freq.items():
if v > root.max:
root.most = [k]
root.max = v
elif v == root.max:
root.most.append(k)
tests:
- name: Integration test
target_processors: /pipeline/processors
input_batch:
- content: Hello world!
- content: This page intentionally left blank.
output_batches:
- # Hello world!
- json_equals:
frequency: {"h": 1, "e": 1, "l": 3, "o": 2, "w": 1, "r": 1, "d": 1}
max: 3
most:
- l
metadata_equals:
key: a string value
complex:
name: Dave
key: a string value
# This page intentionally left blank.
- json_contains:
max: 4
most:
- t
- n
- l
metadata_equals:
key: a string value
complex:
name: Dave
key: a string value