예제 #1
0
    def test_dask_schedulers_list_command(self, mock_scheduler,
                                          mock_pretty_output):
        """
        Test for dask_schedulers_list_command.
        For use with multiple schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler1 = mock.MagicMock(name='test1')
        mock_scheduler1.name = 'test_name1'
        mock_scheduler1.host = 'test_host1'
        mock_scheduler1.timeout = 10
        mock_scheduler1.heartbeat_interval = 5
        mock_scheduler1.dashboard = 'test_dashboard1'
        mock_scheduler.objects.all.return_value = [mock_scheduler1]

        mock_args = mock.MagicMock(type='dask')

        schedulers_list_command(mock_args)

        po_call_args = mock_pretty_output().__enter__().write.call_args_list

        self.assertEqual(2, len(po_call_args))
        self.assertIn('Name', po_call_args[0][0][0])
        self.assertIn('Host', po_call_args[0][0][0])
        self.assertIn('Timeout', po_call_args[0][0][0])
        self.assertIn('Heartbeat Interval', po_call_args[0][0][0])
        self.assertIn('Dashboard', po_call_args[0][0][0])
        self.assertIn('test_name1', po_call_args[1][0][0])
        self.assertIn('test_host1', po_call_args[1][0][0])
        self.assertIn('10', po_call_args[1][0][0])
        self.assertIn('5', po_call_args[1][0][0])
        self.assertIn('test_dashboard1', po_call_args[1][0][0])
예제 #2
0
    def test_schedulers_list_command(self, mock_scheduler, mock_pretty_output):
        """
        Test for schedulers_list_command.
        For use with multiple schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler1 = mock.MagicMock(name='test1')
        mock_scheduler1.name = 'test_name1'
        mock_scheduler1.host = 'test_host1'
        mock_scheduler1.username = '******'
        mock_scheduler1.private_key_path = 'test_path1'
        mock_scheduler1.private_key_pass = '******'
        mock_scheduler2 = mock.MagicMock()
        mock_scheduler2.name = 'test_name2'
        mock_scheduler2.host = 'test_host2'
        mock_scheduler2.username = '******'
        mock_scheduler2.private_key_path = 'test_path2'
        mock_scheduler2.private_key_pass = '******'
        mock_scheduler.objects.all.return_value = [
            mock_scheduler1, mock_scheduler2
        ]
        mock_args = mock.MagicMock()
        schedulers_list_command(mock_args)

        po_call_args = mock_pretty_output().__enter__().write.call_args_list
        self.assertEqual(3, len(po_call_args))
        self.assertIn('Name', po_call_args[0][0][0])
        self.assertIn('Host', po_call_args[0][0][0])
        self.assertIn('Username', po_call_args[0][0][0])
        self.assertIn('Password', po_call_args[0][0][0])
        self.assertIn('Private Key Path', po_call_args[0][0][0])
        self.assertIn('Private Key Pass', po_call_args[0][0][0])
예제 #3
0
    def test_dask_schedulers_list_command(self, mock_scheduler, mock_pretty_output):
        """
        Test for dask_schedulers_list_command.
        For use with multiple schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler1 = mock.MagicMock(name='test1')
        mock_scheduler1.name = 'test_name1'
        mock_scheduler1.host = 'test_host1'
        mock_scheduler1.timeout = 10
        mock_scheduler1.heartbeat_interval = 5
        mock_scheduler1.dashboard = 'test_dashboard1'
        mock_scheduler.objects.all.return_value = [mock_scheduler1]

        mock_args = mock.MagicMock(type='dask')

        schedulers_list_command(mock_args)

        po_call_args = mock_pretty_output().__enter__().write.call_args_list

        self.assertEqual(2, len(po_call_args))
        self.assertIn('Name', po_call_args[0][0][0])
        self.assertIn('Host', po_call_args[0][0][0])
        self.assertIn('Timeout', po_call_args[0][0][0])
        self.assertIn('Heartbeat Interval', po_call_args[0][0][0])
        self.assertIn('Dashboard', po_call_args[0][0][0])
        self.assertIn('test_name1', po_call_args[1][0][0])
        self.assertIn('test_host1', po_call_args[1][0][0])
        self.assertIn('10', po_call_args[1][0][0])
        self.assertIn('5', po_call_args[1][0][0])
        self.assertIn('test_dashboard1', po_call_args[1][0][0])
예제 #4
0
    def test_condor_schedulers_list_command_no_schedulers(self, mock_scheduler, mock_pretty_output):
        """
        Test for condor_schedulers_list_command.
        For use with no schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler.objects.all.return_value = []
        mock_args = mock.MagicMock(type='condor')

        schedulers_list_command(mock_args)

        mock_scheduler.objects.all.assert_called()

        po_call_args = mock_pretty_output().__enter__().write.call_args_list
        self.assertEqual(1, len(po_call_args))
        self.assertEqual('There are no Condor Schedulers registered in Tethys.', po_call_args[0][0][0])
예제 #5
0
    def test_schedulers_list_command_no_schedulers(self, mock_scheduler,
                                                   mock_pretty_output):
        """
        Test for schedulers_list_command.
        For use with no schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler.objects.all.return_value = []
        mock_args = mock.MagicMock()
        schedulers_list_command(mock_args)

        mock_scheduler.objects.all.assert_called()

        po_call_args = mock_pretty_output().__enter__().write.call_args_list
        self.assertEqual(1, len(po_call_args))
        self.assertEqual('There are no Schedulers registered in Tethys.',
                         po_call_args[0][0][0])
예제 #6
0
    def test_condor_schedulers_list_command(self, mock_scheduler, mock_pretty_output):
        """
        Test for condor_schedulers_list_command.
        For use with multiple schedulers.
        :param mock_scheduler:  mock for Scheduler
        :param mock_pretty_output:  mock for pretty_output text
        :return:
        """
        mock_scheduler1 = mock.MagicMock(name='test1')
        mock_scheduler1.name = 'test_name1'
        mock_scheduler1.host = 'test_host1'
        mock_scheduler1.username = '******'
        mock_scheduler1.private_key_path = 'test_path1'
        mock_scheduler1.private_key_pass = '******'
        mock_scheduler2 = mock.MagicMock()
        mock_scheduler2.name = 'test_name2'
        mock_scheduler2.host = 'test_host2'
        mock_scheduler2.username = '******'
        mock_scheduler2.private_key_path = 'test_path2'
        mock_scheduler2.private_key_pass = '******'
        mock_scheduler.objects.all.return_value = [mock_scheduler1, mock_scheduler2]

        mock_args = mock.MagicMock(type='condor')

        # Call the function
        schedulers_list_command(mock_args)

        po_call_args = mock_pretty_output().__enter__().write.call_args_list

        self.assertEqual(3, len(po_call_args))
        self.assertIn('Name', po_call_args[0][0][0])
        self.assertIn('Host', po_call_args[0][0][0])
        self.assertIn('Username', po_call_args[0][0][0])
        self.assertIn('Password', po_call_args[0][0][0])
        self.assertIn('Private Key Path', po_call_args[0][0][0])
        self.assertIn('Private Key Pass', po_call_args[0][0][0])