def test_deploy_to_case_2( self, install_uni_flows_mocked, install_nni_flows_mocked, deploy_mocked, _, requests_mock, ): """Test deploy with all links up.""" deploy_mocked.return_value = True response = MagicMock() response.status_code = 201 requests_mock.return_value = response primary_path = [ get_link_mocked(status=EntityStatus.UP), get_link_mocked(status=EntityStatus.UP), ] attributes = { "controller": get_controller_mock(), "name": "circuit_4", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "primary_path": primary_path, "enabled": True, } evc = EVC(**attributes) deployed = evc.deploy_to("primary_path", evc.primary_path) install_uni_flows_mocked.assert_called_with(evc.primary_path) install_nni_flows_mocked.assert_called_with(evc.primary_path) self.assertTrue(deployed)
def test_deploy_to_case_2(self, install_uni_flows_mocked, install_nni_flows_mocked, deploy_mocked): """Test deploy with all links up.""" deploy_mocked.return_value = True primary_path = [ get_link_mocked(status=EntityStatus.UP), get_link_mocked(status=EntityStatus.UP) ] attributes = { "controller": get_controller_mock(), "name": "circuit_name", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "primary_path": primary_path, "enabled": True } evc = EVC(**attributes) # storehouse mock evc._storehouse.box = Mock() # pylint: disable=protected-access evc._storehouse.box.data = {} # pylint: disable=protected-access deployed = evc.deploy_to('primary_path', evc.primary_path) install_uni_flows_mocked.assert_called_with(evc.primary_path) install_nni_flows_mocked.assert_called_with(evc.primary_path) self.assertTrue(deployed)
def test_deploy_to_case_1(self, log_mocked): """Test if the path is equal to current_path.""" primary_path = [ get_link_mocked(endpoint_a_port=10, endpoint_b_port=9, metadata={"s_vlan": 5}), get_link_mocked(endpoint_a_port=12, endpoint_b_port=11, metadata={"s_vlan": 6}), ] attributes = { "controller": get_controller_mock(), "name": "circuit_3", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "primary_path": primary_path, } evc = EVC(**attributes) evc.current_path = evc.primary_path expected_deployed = evc.deploy_to("primary_path", evc.primary_path) expected_msg = "primary_path is equal to current_path." log_mocked.debug.assert_called_with(expected_msg) self.assertTrue(expected_deployed)
def test_deploy_to_case_3(self, requests_mocked): # pylint: disable=unused-argument """Test deploy with one link down.""" link1 = get_link_mocked() link2 = get_link_mocked() link1.id = "abc" link2.id = "def" primary_path = [link1, link2] attributes = { "controller": get_controller_mock(), "name": "circuit_5", "uni_a": get_uni_mocked(is_valid=True), "uni_z": get_uni_mocked(is_valid=True), "primary_path": primary_path, "enabled": True, } evc = EVC(**attributes) # storehouse initialization mock evc._storehouse.box = Mock() # pylint: disable=protected-access evc._storehouse.box.data = {} # pylint: disable=protected-access deployed = evc.deploy_to("primary_path", evc.primary_path) self.assertFalse(deployed)