build.tests.helpers   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 31
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_topology_mock() 0 23 1
1
"""Module to help to create tests."""
2 1
from unittest.mock import MagicMock
3
4 1
from kytos.lib.helpers import (get_interface_mock, get_link_mock,
5
                               get_switch_mock)
6
7
8 1
def get_topology_mock():
9
    """Create a default topology."""
10 1
    switch_a = get_switch_mock("00:00:00:00:00:00:00:01", 0x04)
11 1
    switch_b = get_switch_mock("00:00:00:00:00:00:00:02", 0x04)
12
13 1
    interface_a1 = get_interface_mock("s1-eth1", 1, switch_a)
14 1
    interface_a2 = get_interface_mock("s1-eth2", 2, switch_a)
15
16 1
    interface_b1 = get_interface_mock("s2-eth1", 1, switch_b)
17 1
    interface_b2 = get_interface_mock("s2-eth2", 2, switch_b)
18
19 1
    switch_a.interfaces = {interface_a1.id: interface_a1,
20
                           interface_a2.id: interface_a2}
21 1
    switch_b.interfaces = {interface_b1.id: interface_b1,
22
                           interface_b2.id: interface_b2}
23
24 1
    link_1 = get_link_mock(interface_a1, interface_b1)
25
26 1
    topology = MagicMock()
27 1
    topology.links = {"1": link_1}
28 1
    topology.switches = {switch_a.dpid: switch_a,
29
                         switch_b.dpid: switch_b}
30
    return topology
31