Esempio n. 1
0
def step_impl(context):
    namespace = Namespace('')
    try:
        namespace.create()
    except Exception as e:
        context.exception = e
Esempio n. 2
0
def step_impl(context, namespace_name):
    namespace = Namespace(namespace_name)
    if namespace not in Namespace.discover():
        namespace.create()
Esempio n. 3
0
 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()
Esempio n. 4
0
 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')
Esempio n. 5
0
 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)