File: test_event.py

package info (click to toggle)
python-opentelemetry 1.39.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,968 kB
  • sloc: python: 53,083; sh: 398; makefile: 142; sql: 39
file content (21 lines) | stat: -rw-r--r-- 752 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
import unittest

from opentelemetry._events import Event


class TestEvent(unittest.TestCase):
    def test_event(self):
        event = Event("example", 123, attributes={"key": "value"})
        self.assertEqual(event.name, "example")
        self.assertEqual(event.timestamp, 123)
        self.assertEqual(
            event.attributes, {"key": "value", "event.name": "example"}
        )

    def test_event_name_copied_in_attributes(self):
        event = Event("name", 123)
        self.assertEqual(event.attributes, {"event.name": "name"})

    def test_event_name_has_precedence_over_attributes(self):
        event = Event("name", 123, attributes={"event.name": "attr value"})
        self.assertEqual(event.attributes, {"event.name": "name"})