def step_impl(context): namespace = Namespace('') try: namespace.create() except Exception as e: context.exception = e
def step_impl(context, namespace_name): namespace = Namespace(namespace_name) if namespace not in Namespace.discover(): namespace.create()
def test_default_namespace_creation(self, execute_command, unify): namespace = Namespace(Namespace.DEFAULT_NAMESPACE_NAME) with self.assertRaises(ObjectAlreadyExistsException): namespace.create() execute_command.assert_not_called()
def test_existing_namespace_creation(self, execute_command, unify): execute_command.side_effect = ['namespace'] namespace = Namespace('namespace') with self.assertRaises(ObjectAlreadyExistsException): namespace.create() execute_command.assert_called_once_with('ip netns list')
def test_namespace_creation(self, execute_command, unify): namespace = Namespace('namespace') namespace.create() self.assertTrue(execute_command.call_count, 2) self.assertTrue(call('ip netns list') in execute_command.mock_calls) self.assertTrue(call('ip netns add namespace') in execute_command.mock_calls)