def test_namespace_deletion(self, execute_command, unify): execute_command.side_effect = ['namespace', None] namespace = Namespace('namespace') namespace.delete() self.assertTrue(execute_command.call_count, 2) self.assertTrue(call('ip netns list') in execute_command.mock_calls) self.assertTrue(call('ip netns del namespace') in execute_command.mock_calls)
def step_impl(context): namespace = Namespace('') try: namespace.delete() except Exception as e: context.exception = e
def step_impl(context, namespace_name): namespace = Namespace(namespace_name) if namespace in Namespace.discover(): namespace.delete()
def test_non_existing_namespace_deletion(self, execute_command, unify): namespace = Namespace('namespace') with self.assertRaises(ObjectNotFoundException): namespace.delete() execute_command.assert_called_once_with('ip netns list')
def test_default_namespace_deletion(self, execute_command, unify): execute_command.side_effect = [''] namespace = Namespace(Namespace.DEFAULT_NAMESPACE_NAME) with self.assertRaises(ForbiddenException): namespace.delete() execute_command.assert_not_called()