Test Failed
Pull Request — master (#68)
by Arturo
03:50 queued 01:43
created

build.tests.integration.metadata_settings   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 222
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 149
dl 0
loc 222
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A MetadataSettings.adding_metadata_2() 0 37 1
A MetadataSettings.setting_links_1() 0 11 1
A MetadataSettings.setting_switches_interfaces_1() 0 21 1
A MetadataSettings.setting_switches_interfaces() 0 17 1
A MetadataSettings.generate_topology_2() 0 15 1
A MetadataSettings.adding_metadata_1() 0 23 1
A MetadataSettings.setting_links() 0 16 1
A MetadataSettings.generate_topology() 0 14 1
A MetadataSettings.generate_topology_1() 0 15 1
A MetadataSettings.adding_metadata() 0 37 1
1
"""Module to overwrite all the needed methods to test the KytosGraph in graph.py"""
2
from tests.integration.test_results import TestResults
3
4
5
class MetadataSettings(TestResults):
6
    """Class to setups all the settings related to topology."""
7
    @staticmethod
8
    def generate_topology():
9
        """Generates a predetermined topology."""
10
        switches = {}
11
        interfaces = {}
12
        links = {}
13
14
        MetadataSettings.setting_switches_interfaces(interfaces, switches)
15
16
        MetadataSettings.setting_links(interfaces, links)
17
18
        MetadataSettings.adding_metadata(links)
19
20
        return switches, links
21
22
    @staticmethod
23
    def setting_switches_interfaces(interfaces, switches):
24
        """Generates the switches in a a predetermined topology."""
25
        TestResults.create_switch("User1", switches)
26
        TestResults.add_interfaces(3, switches["User1"], interfaces)
27
28
        TestResults.create_switch("S2", switches)
29
        TestResults.add_interfaces(2, switches["S2"], interfaces)
30
31
        TestResults.create_switch("User2", switches)
32
        TestResults.add_interfaces(3, switches["User2"], interfaces)
33
34
        TestResults.create_switch("S4", switches)
35
        TestResults.add_interfaces(4, switches["S4"], interfaces)
36
37
        TestResults.create_switch("S5", switches)
38
        TestResults.add_interfaces(2, switches["S5"], interfaces)
39
40
    @staticmethod
41
    def setting_links(interfaces, links):
42
        """Generates the links in a a predetermined topology."""
43
        TestResults.create_link("User1:1", "S2:1", interfaces, links)
44
45
        TestResults.create_link("User1:2", "S5:1", interfaces, links)
46
47
        TestResults.create_link("User1:3", "S4:1", interfaces, links)
48
49
        TestResults.create_link("S2:2", "User2:1", interfaces, links)
50
51
        TestResults.create_link("User2:2", "S4:2", interfaces, links)
52
53
        TestResults.create_link("S5:2", "S4:3", interfaces, links)
54
55
        TestResults.create_link("User2:3", "S4:4", interfaces, links)
56
57
    @staticmethod
58
    def adding_metadata(links):
59
        """Add the links' metadata in a a predetermined topology."""
60
        TestResults.add_metadata_to_link(
61
            "User1:1", "S2:1", {
62
                "reliability": 3, "ownership": "B", "delay": 30,
63
                "bandwidth": 20}, links)
64
65
        TestResults.add_metadata_to_link(
66
            "User1:2", "S5:1", {
67
                "reliability": 1, "ownership": "A", "delay": 5,
68
                "bandwidth": 50}, links)
69
70
        TestResults.add_metadata_to_link(
71
            "User1:3", "S4:1", {
72
                "reliability": 3, "ownership": "A", "delay": 60,
73
                "bandwidth": 10}, links)
74
75
        TestResults.add_metadata_to_link(
76
            "S2:2", "User2:1", {
77
                "reliability": 3, "ownership": "B", "delay": 30,
78
                "bandwidth": 20}, links)
79
80
        TestResults.add_metadata_to_link(
81
            "User2:2", "S4:2", {
82
                "reliability": 3, "ownership": "B", "delay": 30,
83
                "bandwidth": 10}, links)
84
85
        TestResults.add_metadata_to_link(
86
            "S5:2", "S4:3", {
87
                "reliability": 1, "ownership": "A", "delay": 10,
88
                "bandwidth": 50}, links)
89
90
        TestResults.add_metadata_to_link(
91
            "User2:3", "S4:4", {
92
                "reliability": 3, "ownership": "A", "delay": 29,
93
                "bandwidth": 20}, links)
94
95
    @staticmethod
96
    def generate_topology_1():
97
        """Generates a predetermined topology
98
        - 2nd Variant."""
99
        switches = {}
100
        interfaces = {}
101
        links = {}
102
103
        MetadataSettings.setting_switches_interfaces_1(interfaces, switches)
104
105
        MetadataSettings.setting_links_1(interfaces, links)
106
107
        MetadataSettings.adding_metadata_1(links)
108
109
        return switches, links
110
111
    @staticmethod
112
    def setting_switches_interfaces_1(interfaces, switches):
113
        """Generates the switches in a a predetermined topology
114
        - 2nd variant."""
115
        TestResults.create_switch("User1", switches)
116
        TestResults.add_interfaces(2, switches["User1"], interfaces)
117
118
        TestResults.create_switch("User2", switches)
119
        TestResults.add_interfaces(2, switches["User2"], interfaces)
120
121
        TestResults.create_switch("User3", switches)
122
        TestResults.add_interfaces(2, switches["User3"], interfaces)
123
124
        TestResults.create_switch("S1", switches)
125
        TestResults.add_interfaces(1, switches["S1"], interfaces)
126
127
        TestResults.create_switch("S2", switches)
128
        TestResults.add_interfaces(1, switches["S2"], interfaces)
129
130
        TestResults.create_switch("S3", switches)
131
        TestResults.add_interfaces(2, switches["S3"], interfaces)
132
133
    @staticmethod
134
    def setting_links_1(interfaces, links):
135
        """Generates the links in a a predetermined topology
136
        - 2nd Variant."""
137
        TestResults.create_link("User1:1", "S1:1", interfaces, links)
138
139
        TestResults.create_link("User1:2", "S3:1", interfaces, links)
140
141
        TestResults.create_link("User2:1", "S2:1", interfaces, links)
142
143
        TestResults.create_link("User3:1", "S3:2", interfaces, links)
144
145
    @staticmethod
146
    def adding_metadata_1(links):
147
        """Add the links' metadata in a a predetermined topology
148
        - 2nd Variant."""
149
        TestResults.add_metadata_to_link(
150
            "User1:1", "S1:1", {
151
                "reliability": 3, "ownership": "B", "delay": 30,
152
                "bandwidth": 20}, links)
153
154
        TestResults.add_metadata_to_link(
155
            "User1:2", "S3:1", {
156
                "reliability": 1, "ownership": "A", "delay": 5,
157
                "bandwidth": 50}, links)
158
159
        TestResults.add_metadata_to_link(
160
            "User2:1", "S2:1", {
161
                "reliability": 3, "ownership": "A", "delay": 60,
162
                "bandwidth": 10}, links)
163
164
        TestResults.add_metadata_to_link(
165
            "User3:1", "S3:2", {
166
                "reliability": 3, "ownership": "B", "delay": 30,
167
                "bandwidth": 20}, links)
168
169
    @staticmethod
170
    def generate_topology_2():
171
        """Generates a predetermined topology
172
        - 3rd Variant."""
173
        switches = {}
174
        interfaces = {}
175
        links = {}
176
177
        MetadataSettings.setting_switches_interfaces(interfaces, switches)
178
179
        MetadataSettings.setting_links(interfaces, links)
180
181
        MetadataSettings.adding_metadata_2(links)
182
183
        return switches, links
184
185
    @staticmethod
186
    def adding_metadata_2(links):
187
        """Add the links' metadata in a a predetermined topology
188
        - 3rd Variant."""
189
        TestResults.add_metadata_to_link(
190
            "User1:1", "S2:1", {
191
                "reliability": 3, "ownership": "B",
192
                "bandwidth": 20}, links)
193
194
        TestResults.add_metadata_to_link(
195
            "User1:2", "S5:1", {
196
                "reliability": 1, "delay": 5,
197
                "bandwidth": 50}, links)
198
199
        TestResults.add_metadata_to_link(
200
            "User1:3", "S4:1", {
201
                "ownership": "A", "delay": 60,
202
                "bandwidth": 10}, links)
203
204
        TestResults.add_metadata_to_link(
205
            "S2:2", "User2:1", {
206
                "reliability": 3,
207
                "bandwidth": 20}, links)
208
209
        TestResults.add_metadata_to_link(
210
            "User2:2", "S4:2", {
211
                "ownership": "B",
212
                "bandwidth": 10}, links)
213
214
        TestResults.add_metadata_to_link(
215
            "S5:2", "S4:3", {
216
                "delay": 10,
217
                "bandwidth": 50}, links)
218
219
        TestResults.add_metadata_to_link(
220
            "User2:3", "S4:4", {
221
                "bandwidth": 20}, links)
222