Total Complexity | 1 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
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 |