Beispiel #1
0
 def test_can_run_the_status_action_for_all_containers_of_a_project(
         self, mock_project_status, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['status'])
     assert mock_project_status.call_count == 1
     assert mock_project_status.call_args == [
         {
             'container_names': [],
         },
     ]
Beispiel #2
0
 def test_can_run_the_destroy_containers_using_a_force_option(
         self, container_exists_mock, mock_project_destroy, mock_project):
     container_exists_mock.__get__ = unittest.mock.Mock(return_value=True)
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['destroy', '--force'])
     assert mock_project_destroy.call_count == 1
     assert mock_project_destroy.call_args == [
         {
             'container_names': [],
         },
     ]
Beispiel #3
0
 def test_can_run_the_up_action_for_all_containers_of_a_project(
         self, mock_project_up, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['up'])
     assert mock_project_up.call_count == 1
     assert mock_project_up.call_args == [
         {
             'container_names': [],
             'provisioning_mode': None,
         },
     ]
Beispiel #4
0
 def test_can_force_the_destroy_action_if_the_containers_do_not_exist(
         self, container_exists_mock, mock_project_destroy, mock_project):
     container_exists_mock.__get__ = unittest.mock.Mock(return_value=False)
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['destroy'])
     assert mock_project_destroy.call_count == 1
     assert mock_project_destroy.call_args == [
         {
             'container_names': [],
         },
     ]
Beispiel #5
0
 def test_can_run_shell_command_for_a_specific_user_and_container(
         self, mock_project_shell, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['shell', '-u', 'foobar', 'c1', '-c', 'cd /; ls -l'])
     assert mock_project_shell.call_count == 1
     assert mock_project_shell.call_args == [
         {
             'container_name': 'c1',
             'username': '******',
             'command': 'cd /; ls -l'
         },
     ]
Beispiel #6
0
 def test_can_run_the_shell_action_for_a_specific_container(
         self, mock_project_shell, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['shell', 'c1'])
     assert mock_project_shell.call_count == 1
     assert mock_project_shell.call_args == [
         {
             'container_name': 'c1',
             'username': None,
             'command': None
         },
     ]
Beispiel #7
0
 def test_can_run_shell_command_for_a_specific_container(
         self, mock_project_shell, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['shell', 'c1', '-c', 'echo', 'he re"s', '-u', '$PATH'])
     assert mock_project_shell.call_count == 1
     assert mock_project_shell.call_args == [
         {
             'container_name': 'c1',
             'username': None,
             'cmd_args': ['echo', 'he re\"s', '-u', '$PATH']
         },
     ]
Beispiel #8
0
 def test_can_run_the_provision_action_for_specific_containers(
         self, mock_project_provision, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['provision', 'c1', 'c2'])
     assert mock_project_provision.call_count == 1
     assert mock_project_provision.call_args == [
         {
             'container_names': [
                 'c1',
                 'c2',
             ],
         },
     ]
Beispiel #9
0
 def test_can_run_the_destroy_action_for_specific_containers(
         self, container_exists_mock, mock_project_destroy, mock_project,
         y_mock):
     container_exists_mock.__get__ = unittest.mock.Mock(return_value=True)
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock(['destroy', 'default'])
     assert mock_project_destroy.call_count == 1
     assert mock_project_destroy.call_args == [
         {
             'container_names': [
                 'default',
             ],
         },
     ]
Beispiel #10
0
 def test_can_run_the_up_action_with_provisioning_disabled(
         self, mock_project_up, mock_project):
     mock_project.__get__ = unittest.mock.Mock(
         return_value=get_project(os.path.join(FIXTURE_ROOT, 'project01')))
     LXDock([
         'up',
         '--no-provision',
     ])
     assert mock_project_up.call_count == 1
     assert mock_project_up.call_args == [
         {
             'container_names': [],
             'provisioning_mode': ProvisioningMode.DISABLED,
         },
     ]
Beispiel #11
0
def test_get_project_function_can_return_a_valid_project_instance():
    homedir = os.path.join(FIXTURE_ROOT, 'project01')
    project = get_project(homedir)
    assert project.name == 'project01'
    assert project.homedir == homedir