|  | @@ 2059-2100 (lines=42) @@ | 
                                                            
                                    | 2056 |  |             content={"1": "FailoverEvent1"} | 
                                                            
                                    | 2057 |  |         ) | 
                                                            
                                    | 2058 |  |  | 
                                                            
                                    | 2059 |  |     @patch("napps.kytos.mef_eline.main.emit_event") | 
                                                            
                                    | 2060 |  |     @patch("napps.kytos.mef_eline.main.send_flow_mods_http") | 
                                                            
                                    | 2061 |  |     def test_execute_swap_to_failover_exception( | 
                                                            
                                    | 2062 |  |         self, | 
                                                            
                                    | 2063 |  |         send_flow_mods_mock: MagicMock, | 
                                                            
                                    | 2064 |  |         emit_main_mock: MagicMock, | 
                                                            
                                    | 2065 |  |     ): | 
                                                            
                                    | 2066 |  |         """Test handle_link_down method when an exception occurs.""" | 
                                                            
                                    | 2067 |  |         evc1 = MagicMock(id="1") | 
                                                            
                                    | 2068 |  |         good_path = MagicMock(id="GoodPath") | 
                                                            
                                    | 2069 |  |         bad_path = MagicMock(id="BadPath") | 
                                                            
                                    | 2070 |  |         evc1.current_path = bad_path | 
                                                            
                                    | 2071 |  |         evc1.failover_path = good_path | 
                                                            
                                    | 2072 |  |         evc2 = MagicMock(id="2") | 
                                                            
                                    | 2073 |  |  | 
                                                            
                                    | 2074 |  |         self.napp.prepare_swap_to_failover_flow = { | 
                                                            
                                    | 2075 |  |             evc1: {"1": ["Flow1"]}, | 
                                                            
                                    | 2076 |  |             evc2: None | 
                                                            
                                    | 2077 |  |         }.get | 
                                                            
                                    | 2078 |  |  | 
                                                            
                                    | 2079 |  |         self.napp.prepare_swap_to_failover_event = { | 
                                                            
                                    | 2080 |  |             evc1: "FailoverEvent1", | 
                                                            
                                    | 2081 |  |         }.get | 
                                                            
                                    | 2082 |  |  | 
                                                            
                                    | 2083 |  |         send_flow_mods_mock.side_effect = FlowModException( | 
                                                            
                                    | 2084 |  |             "Flowmod failed to send" | 
                                                            
                                    | 2085 |  |         ) | 
                                                            
                                    | 2086 |  |  | 
                                                            
                                    | 2087 |  |         success, failure = self.napp.execute_swap_to_failover([evc1, evc2]) | 
                                                            
                                    | 2088 |  |  | 
                                                            
                                    | 2089 |  |         assert success == [] | 
                                                            
                                    | 2090 |  |         assert failure == [evc1, evc2] | 
                                                            
                                    | 2091 |  |  | 
                                                            
                                    | 2092 |  |         send_flow_mods_mock.assert_called_with( | 
                                                            
                                    | 2093 |  |             {"1": ["Flow1"]}, | 
                                                            
                                    | 2094 |  |             "install" | 
                                                            
                                    | 2095 |  |         ) | 
                                                            
                                    | 2096 |  |  | 
                                                            
                                    | 2097 |  |         assert evc1.current_path == bad_path | 
                                                            
                                    | 2098 |  |         assert evc1.failover_path == good_path | 
                                                            
                                    | 2099 |  |  | 
                                                            
                                    | 2100 |  |         emit_main_mock.assert_not_called() | 
                                                            
                                    | 2101 |  |  | 
                                                            
                                    | 2102 |  |     @patch("napps.kytos.mef_eline.main.emit_event") | 
                                                            
                                    | 2103 |  |     @patch("napps.kytos.mef_eline.main.send_flow_mods_http") | 
                                                                                
                                |  | @@ 2016-2056 (lines=41) @@ | 
                                                            
                                    | 2013 |  |             evc6.as_dict(), | 
                                                            
                                    | 2014 |  |         ]) | 
                                                            
                                    | 2015 |  |  | 
                                                            
                                    | 2016 |  |     @patch("napps.kytos.mef_eline.main.emit_event") | 
                                                            
                                    | 2017 |  |     @patch("napps.kytos.mef_eline.main.send_flow_mods_http") | 
                                                            
                                    | 2018 |  |     def test_execute_swap_to_failover( | 
                                                            
                                    | 2019 |  |         self, | 
                                                            
                                    | 2020 |  |         send_flow_mods_mock: MagicMock, | 
                                                            
                                    | 2021 |  |         emit_main_mock: MagicMock, | 
                                                            
                                    | 2022 |  |     ): | 
                                                            
                                    | 2023 |  |         """Test execute_swap_to_failover method.""" | 
                                                            
                                    | 2024 |  |         evc1 = MagicMock(id="1") | 
                                                            
                                    | 2025 |  |         good_path = MagicMock(id="GoodPath") | 
                                                            
                                    | 2026 |  |         bad_path = MagicMock(id="BadPath") | 
                                                            
                                    | 2027 |  |         evc1.current_path = bad_path | 
                                                            
                                    | 2028 |  |         evc1.failover_path = good_path | 
                                                            
                                    | 2029 |  |         evc2 = MagicMock(id="2") | 
                                                            
                                    | 2030 |  |  | 
                                                            
                                    | 2031 |  |         self.napp.prepare_swap_to_failover_flow = { | 
                                                            
                                    | 2032 |  |             evc1: {"1": ["Flow1"]}, | 
                                                            
                                    | 2033 |  |             evc2: None | 
                                                            
                                    | 2034 |  |         }.get | 
                                                            
                                    | 2035 |  |  | 
                                                            
                                    | 2036 |  |         self.napp.prepare_swap_to_failover_event = { | 
                                                            
                                    | 2037 |  |             evc1: "FailoverEvent1", | 
                                                            
                                    | 2038 |  |         }.get | 
                                                            
                                    | 2039 |  |  | 
                                                            
                                    | 2040 |  |         success, failure = self.napp.execute_swap_to_failover([evc1, evc2]) | 
                                                            
                                    | 2041 |  |  | 
                                                            
                                    | 2042 |  |         assert success == [evc1] | 
                                                            
                                    | 2043 |  |         assert failure == [evc2] | 
                                                            
                                    | 2044 |  |  | 
                                                            
                                    | 2045 |  |         send_flow_mods_mock.assert_called_with( | 
                                                            
                                    | 2046 |  |             {"1": ["Flow1"]}, | 
                                                            
                                    | 2047 |  |             "install" | 
                                                            
                                    | 2048 |  |         ) | 
                                                            
                                    | 2049 |  |  | 
                                                            
                                    | 2050 |  |         assert evc1.current_path == good_path | 
                                                            
                                    | 2051 |  |         assert evc1.failover_path == bad_path | 
                                                            
                                    | 2052 |  |  | 
                                                            
                                    | 2053 |  |         emit_main_mock.assert_called_with( | 
                                                            
                                    | 2054 |  |             self.napp.controller, | 
                                                            
                                    | 2055 |  |             "failover_link_down", | 
                                                            
                                    | 2056 |  |             content={"1": "FailoverEvent1"} | 
                                                            
                                    | 2057 |  |         ) | 
                                                            
                                    | 2058 |  |  | 
                                                            
                                    | 2059 |  |     @patch("napps.kytos.mef_eline.main.emit_event") |