Code Duplication    Length = 24-24 lines in 2 locations

tests/unit/test_napps.py 2 locations

@@ 141-164 (lines=24) @@
138
            self.assertEqual(get_return[0][1], 'of_core')
139
            self.assertEqual(mock_prop_enabled.call_count, 1)
140
141
    def test_get_installed_local(self):
142
        """Test get_installed_local used to find
143
        installed napps in local machine"""
144
        # Mock kytos.json path
145
        mock_path = Mock()
146
147
        def glob_side_effect(args):
148
            """Path.glob to mock finding paths with kytos.json file."""
149
            self.assertEqual(args, "*/*/kytos.json")
150
151
            mock_path1 = Mock()
152
            mock_path1.parts = ['kytos', 'of_core', 'kytos.json']
153
            return [mock_path1]
154
        mock_path.glob = glob_side_effect
155
156
        mock_prop_installed = PropertyMock()
157
        with patch.object(NAppsManager, '_installed', mock_prop_installed):
158
            mock_prop_installed.return_value = mock_path
159
160
            get_return = self.napps_manager.get_installed_local()
161
162
            self.assertEqual(get_return[0][0], 'kytos')
163
            self.assertEqual(get_return[0][1], 'of_core')
164
            self.assertEqual(mock_prop_installed.call_count, 1)
165
166
    @patch('urllib.request.urlopen')
167
    def test_get_installed(self, mock_urlopen):
@@ 116-139 (lines=24) @@
113
        self.assertEqual(get_return[1][0], 'kytos')
114
        self.assertEqual(get_return[1][1], 'of_lldp')
115
116
    def test_get_enabled_local(self):
117
        """Test get_enabled_local used to find
118
        enabled napps in local machine"""
119
        # Mock kytos.json path
120
        mock_path = Mock()
121
122
        def glob_side_effect(args):
123
            """Path.glob to mock finding paths with kytos.json file."""
124
            self.assertEqual(args, "*/*/kytos.json")
125
126
            mock_path1 = Mock()
127
            mock_path1.parts = ['kytos', 'of_core', 'kytos.json']
128
            return [mock_path1]
129
        mock_path.glob = glob_side_effect
130
131
        mock_prop_enabled = PropertyMock()
132
        with patch.object(NAppsManager, '_enabled', mock_prop_enabled):
133
            mock_prop_enabled.return_value = mock_path
134
135
            get_return = self.napps_manager.get_enabled_local()
136
137
            self.assertEqual(get_return[0][0], 'kytos')
138
            self.assertEqual(get_return[0][1], 'of_core')
139
            self.assertEqual(mock_prop_enabled.call_count, 1)
140
141
    def test_get_installed_local(self):
142
        """Test get_installed_local used to find