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