Skip to content

Commit 98ed7ce

Browse files
committed
Test TLL messages using floats, change --ttl type to FLOAT
1 parent 0e35619 commit 98ed7ce

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

riemann_client/client.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ def emit(self, record):
2626

2727
import riemann_client.riemann_pb2
2828
import riemann_client.transport
29-
import google.protobuf.descriptor
30-
3129

3230
logger = logging.getLogger(__name__)
3331
logger.addHandler(NullHandler())
@@ -153,9 +151,6 @@ def create_dict(event):
153151
value = list(value)
154152
elif descriptor.name == 'attributes':
155153
value = dict(((a.key, a.value) for a in value))
156-
elif descriptor.type == \
157-
google.protobuf.descriptor.FieldDescriptor.TYPE_FLOAT:
158-
value = round(value, 1)
159154
data[descriptor.name] = value
160155

161156
return data

riemann_client/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def main(ctx, host, port, transport_type, timeout, ca_certs):
9494
help="Event description")
9595
@click.option('-t', '--tag', type=click.STRING, multiple=True,
9696
help="Event tag (multiple)")
97-
@click.option('-l', '--ttl', type=click.INT,
97+
@click.option('-l', '--ttl', type=click.FLOAT,
9898
help="Event time to live in seconds")
9999
@click.option('-a', '--attr', '--attribute', type=Pair(), multiple=True,
100100
help="Event attribute (key=value, multiple)")

tests/test_riemann_command.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ def test_send_empty_message():
3434
},
3535
"description": "description",
3636
"host": "%s",
37-
"metric_f": 11.1,
37+
"metric_f": 11.5,
3838
"service": "service",
3939
"state": "state",
4040
"tags": [
4141
"tag"
4242
],
4343
"time": 1408030991,
44-
"ttl": 120.0
44+
"ttl": 120.5
4545
}
4646
""" % socket.gethostname()
4747

@@ -51,12 +51,12 @@ def test_send():
5151
u'send',
5252
u'--attribute', u'key=value',
5353
u'--description', u'description',
54-
u'--metric_f', u'11.1',
54+
u'--metric_f', u'11.5',
5555
u'--service', u'service',
5656
u'--state', u'state',
5757
u'--tag', u'tag',
5858
u'--time', u'1408030991',
59-
u'--ttl', u'120'
59+
u'--ttl', u'120.5'
6060
], POPULATED_MESSAGE)
6161

6262

@@ -65,12 +65,12 @@ def test_send_short():
6565
u'send',
6666
u'-a', u'key=value',
6767
u'-d', u'description',
68-
u'-m', u'11.1',
68+
u'-m', u'11.5',
6969
u'-s', u'service',
7070
u'-S', u'state',
7171
u'-t', u'tag',
7272
u'-T', u'1408030991',
73-
u'-l', u'120'
73+
u'-l', u'120.5'
7474
], POPULATED_MESSAGE)
7575

7676

@@ -79,12 +79,12 @@ def test_send_noecho():
7979
'send',
8080
'--attribute', 'key=value',
8181
'--description', 'description',
82-
'--metric_f', '11.1',
82+
'--metric_f', '11.5',
8383
'--service', 'service',
8484
'--state', 'state',
8585
'--tag', 'tag',
8686
'--time', '1408030991',
87-
'--ttl', '120',
87+
'--ttl', '120.5',
8888
'--no-echo'
8989
], '')
9090

0 commit comments

Comments
 (0)