tests.unit.test_core.test_events   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A TestKytosEvent.test_source() 0 6 1
A TestKytosEvent.test_destination() 0 6 1
A TestKytosEvent.setUp() 0 3 1
A TestKytosEvent.test__repr__() 0 9 1
A TestKytosEvent.test__str__() 0 3 1
A TestKytosEvent.test_message() 0 6 1
1
"""Test kytos.core.events module."""
2
from unittest import TestCase
3
4
from kytos.core.events import KytosEvent
5
6
7
class TestKytosEvent(TestCase):
8
    """KytosEvent tests."""
9
10
    def setUp(self):
11
        """Instantiate a KytosEvent."""
12
        self.event = KytosEvent('kytos/core.any')
13
14
    def test__str__(self):
15
        """Test __str__ method."""
16
        self.assertEqual(str(self.event), 'kytos/core.any')
17
18
    def test__repr__(self):
19
        """Test __repr__ method."""
20
        self.event.content = {"destination": "dest",
21
                              "source": "src",
22
                              "message": "msg"}
23
        expected = "KytosEvent('kytos/core.any', {'destination': 'dest', " + \
24
                   "'source': 'src', 'message': 'msg'})"
25
26
        self.assertEqual(repr(self.event), expected)
27
28
    def test_destination(self):
29
        """Test destination property and set_destination method."""
30
        self.assertEqual(self.event.destination, None)
31
32
        self.event.set_destination('dest')
33
        self.assertEqual(self.event.destination, 'dest')
34
35
    def test_source(self):
36
        """Test source property and set_source method."""
37
        self.assertEqual(self.event.source, None)
38
39
        self.event.set_source('src')
40
        self.assertEqual(self.event.source, 'src')
41
42
    def test_message(self):
43
        """Test message property."""
44
        self.assertEqual(self.event.message, None)
45
46
        self.event.content = {"message": "msg"}
47
        self.assertEqual(self.event.message, 'msg')
48