def test_send_flow_mods_case1(self, requests_mock): """Test if you are sending flow_mods.""" flow_mods = {"id": 20} switch = Mock(spec=Switch, id=1) # pylint: disable=protected-access EVC._send_flow_mods(switch, flow_mods) expected_endpoint = f"{MANAGER_URL}/flows/{switch.id}" expected_data = {"flows": flow_mods} self.assertEqual(requests_mock.post.call_count, 1) requests_mock.post.assert_called_once_with(expected_endpoint, json=expected_data)
def test_send_flow_mods_case2(self, requests_mock): """Test if you are sending flow_mods.""" flow_mods = {"id": 20} switch = Mock(spec=Switch, id=1) response = MagicMock() response.status_code = 201 requests_mock.post.return_value = response # pylint: disable=protected-access EVC._send_flow_mods(switch, flow_mods, command='delete', force=True) expected_endpoint = f"{MANAGER_URL}/delete/{switch.id}" expected_data = {"flows": flow_mods, "force": True} self.assertEqual(requests_mock.post.call_count, 1) requests_mock.post.assert_called_once_with(expected_endpoint, json=expected_data)