Code Duplication    Length = 47-47 lines in 2 locations

tests/integration/test_main.py 1 location

@@ 159-205 (lines=47) @@
156
                           '.*.switch.port.created']
157
        self.assertCountEqual(expected_events, actual_events)
158
159
    def test_verify_api_urls(self):
160
        """Verify all APIs registered."""
161
        expected_urls = [
162
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/interfaces'),
163
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/switches'),
164
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/links'),
165
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/'),
166
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
167
          '/api/kytos/topology/v3/interfaces/switch/<dpid>/disable'),
168
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
169
          '/api/kytos/topology/v3/interfaces/switch/<dpid>/enable'),
170
         ({'key': '[key]', 'interface_id': '[interface_id]'},
171
          {'OPTIONS', 'DELETE'},
172
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata/<key>'),
173
         ({'interface_id': '[interface_id]'}, {'POST', 'OPTIONS'},
174
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'),
175
         ({'interface_id': '[interface_id]'}, {'GET', 'OPTIONS', 'HEAD'},
176
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'),
177
         ({'interface_disable_id': '[interface_disable_id]'},
178
          {'POST', 'OPTIONS'},
179
          '/api/kytos/topology/v3/interfaces/<interface_disable_id>/disable'),
180
         ({'interface_enable_id': '[interface_enable_id]'},
181
          {'POST', 'OPTIONS'},
182
          '/api/kytos/topology/v3/interfaces/<interface_enable_id>/enable'),
183
         ({'dpid': '[dpid]', 'key': '[key]'}, {'OPTIONS', 'DELETE'},
184
          '/api/kytos/topology/v3/switches/<dpid>/metadata/<key>'),
185
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
186
          '/api/kytos/topology/v3/switches/<dpid>/metadata'),
187
         ({'dpid': '[dpid]'}, {'GET', 'OPTIONS', 'HEAD'},
188
          '/api/kytos/topology/v3/switches/<dpid>/metadata'),
189
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
190
          '/api/kytos/topology/v3/switches/<dpid>/disable'),
191
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
192
          '/api/kytos/topology/v3/switches/<dpid>/enable'),
193
         ({'link_id': '[link_id]', 'key': '[key]'}, {'OPTIONS', 'DELETE'},
194
          '/api/kytos/topology/v3/links/<link_id>/metadata/<key>'),
195
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
196
          '/api/kytos/topology/v3/links/<link_id>/metadata'),
197
         ({'link_id': '[link_id]'}, {'GET', 'OPTIONS', 'HEAD'},
198
          '/api/kytos/topology/v3/links/<link_id>/metadata'),
199
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
200
          '/api/kytos/topology/v3/links/<link_id>/disable'),
201
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
202
          '/api/kytos/topology/v3/links/<link_id>/enable')]
203
204
        urls = self.get_napp_urls(self.napp)
205
        self.assertEqual(expected_urls, urls)
206
207
    @staticmethod
208
    def get_napp_urls(napp):

tests/unit/test_main.py 1 location

@@ 90-136 (lines=47) @@
87
        actual_events = self.napp.listeners()
88
        self.assertCountEqual(expected_events, actual_events)
89
90
    def test_verify_api_urls(self):
91
        """Verify all APIs registered."""
92
        expected_urls = [
93
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/interfaces'),
94
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/switches'),
95
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/links'),
96
         ({}, {'GET', 'OPTIONS', 'HEAD'}, '/api/kytos/topology/v3/'),
97
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
98
          '/api/kytos/topology/v3/interfaces/switch/<dpid>/disable'),
99
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
100
          '/api/kytos/topology/v3/interfaces/switch/<dpid>/enable'),
101
         ({'key': '[key]', 'interface_id': '[interface_id]'},
102
          {'OPTIONS', 'DELETE'},
103
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata/<key>'),
104
         ({'interface_id': '[interface_id]'}, {'POST', 'OPTIONS'},
105
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'),
106
         ({'interface_id': '[interface_id]'}, {'GET', 'OPTIONS', 'HEAD'},
107
          '/api/kytos/topology/v3/interfaces/<interface_id>/metadata'),
108
         ({'interface_disable_id': '[interface_disable_id]'},
109
          {'POST', 'OPTIONS'},
110
          '/api/kytos/topology/v3/interfaces/<interface_disable_id>/disable'),
111
         ({'interface_enable_id': '[interface_enable_id]'},
112
          {'POST', 'OPTIONS'},
113
          '/api/kytos/topology/v3/interfaces/<interface_enable_id>/enable'),
114
         ({'dpid': '[dpid]', 'key': '[key]'}, {'OPTIONS', 'DELETE'},
115
          '/api/kytos/topology/v3/switches/<dpid>/metadata/<key>'),
116
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
117
          '/api/kytos/topology/v3/switches/<dpid>/metadata'),
118
         ({'dpid': '[dpid]'}, {'GET', 'OPTIONS', 'HEAD'},
119
          '/api/kytos/topology/v3/switches/<dpid>/metadata'),
120
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
121
          '/api/kytos/topology/v3/switches/<dpid>/disable'),
122
         ({'dpid': '[dpid]'}, {'POST', 'OPTIONS'},
123
          '/api/kytos/topology/v3/switches/<dpid>/enable'),
124
         ({'link_id': '[link_id]', 'key': '[key]'}, {'OPTIONS', 'DELETE'},
125
          '/api/kytos/topology/v3/links/<link_id>/metadata/<key>'),
126
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
127
          '/api/kytos/topology/v3/links/<link_id>/metadata'),
128
         ({'link_id': '[link_id]'}, {'GET', 'OPTIONS', 'HEAD'},
129
          '/api/kytos/topology/v3/links/<link_id>/metadata'),
130
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
131
          '/api/kytos/topology/v3/links/<link_id>/disable'),
132
         ({'link_id': '[link_id]'}, {'POST', 'OPTIONS'},
133
          '/api/kytos/topology/v3/links/<link_id>/enable')]
134
135
        urls = get_napp_urls(self.napp)
136
        self.assertEqual(expected_urls, urls)
137
138
    def test_get_link_or_create(self):
139
        """Test _get_link_or_create."""