File: test_protocol.py

package info (click to toggle)
aiodogstatsd 0.16.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 296 kB
  • sloc: python: 1,080; makefile: 70; sh: 19
file content (34 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (2)
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
import pytest

from aiodogstatsd import protocol, typedefs


@pytest.mark.parametrize(
    "in_, out",
    (
        (
            {
                "name": "name_1",
                "namespace": None,
                "value": "value_1",
                "type_": typedefs.MType.COUNTER,
                "tags": {},
                "sample_rate": 1,
            },
            b"name_1:value_1|c",
        ),
        (
            {
                "name": "name_2",
                "namespace": "namespace_2",
                "value": "value_2",
                "type_": typedefs.MType.COUNTER,
                "tags": {"tag_key_1": "tag_value_1", "tag_key_2": "tag_value_2"},
                "sample_rate": 0.5,
            },
            b"namespace_2.name_2:value_2|c|@0.5|#tag_key_1:tag_value_1,tag_key_2:tag_value_2",
        ),
    ),
)
def test_build(in_, out):
    assert out == protocol.build(**in_)