コード例 #1
0
    def test_plenty_available(self, mock_check_queue, mock_corsika_batch):
        """Plenty of space on queue"""

        mock_check_queue.return_value = 50
        n = 10
        with warnings.catch_warnings(record=True) as warned:
            qsub_corsika.multiple_jobs(n,
                                       sentinel.energy,
                                       sentinel.particle,
                                       sentinel.zenith,
                                       sentinel.azimuth,
                                       sentinel.queue,
                                       sentinel.corsika,
                                       progress=False)
        mock_check_queue.assert_called_once_with(sentinel.queue)
        mock_corsika_batch.assert_called_with(energy=sentinel.energy,
                                              particle=sentinel.particle,
                                              zenith=sentinel.zenith,
                                              azimuth=sentinel.azimuth,
                                              queue=sentinel.queue,
                                              corsika=sentinel.corsika)
        mock_corsika_batch.return_value.run.assert_called_with()
        # This is twice as often because it includes the calls to run()
        self.assertEqual(len(mock_corsika_batch.mock_calls), n * 2)
        self.assertEqual(len(mock_corsika_batch.return_value.run.mock_calls),
                         n)
        self.assertEqual(len(warned), 0)
コード例 #2
0
    def test_one_available_wanted_more(self, mock_check_queue, mock_corsika_batch):
        """Only one slot available on queue"""

        mock_check_queue.return_value = 1
        with warnings.catch_warnings(record=True) as warned:
            qsub_corsika.multiple_jobs(2, sentinel.energy, sentinel.particle,
                                       sentinel.zenith, sentinel.azimuth,
                                       sentinel.queue, sentinel.corsika,
                                       progress=False)
        mock_check_queue.assert_called_once_with(sentinel.queue)
        mock_corsika_batch.assert_called_once_with(
            energy=sentinel.energy, particle=sentinel.particle,
            zenith=sentinel.zenith, azimuth=sentinel.azimuth,
            queue=sentinel.queue, corsika=sentinel.corsika)
        mock_corsika_batch.return_value.run.assert_called_once_with()
        self.assertEqual(len(warned), 1)
コード例 #3
0
ファイル: test_qsub_corsika.py プロジェクト: HiSPARC/sapphire
    def test_two_available_wanted_more(self, mock_check_queue, mock_corsika_batch):
        """Only two slots available on queue"""

        mock_check_queue.return_value = 2
        with warnings.catch_warnings(record=True) as warned:
            qsub_corsika.multiple_jobs(3, sentinel.energy, sentinel.particle,
                                       sentinel.zenith, sentinel.azimuth,
                                       sentinel.queue, sentinel.corsika,
                                       progress=False)
        mock_check_queue.assert_called_once_with(sentinel.queue)
        mock_corsika_batch.assert_called_with(
            energy=sentinel.energy, particle=sentinel.particle,
            zenith=sentinel.zenith, azimuth=sentinel.azimuth,
            queue=sentinel.queue, corsika=sentinel.corsika)
        mock_corsika_batch.return_value.run.assert_called_with()
        # This is twice as often because it includes the calls to run()
        self.assertEqual(len(mock_corsika_batch.mock_calls), 4)
        self.assertEqual(len(mock_corsika_batch.return_value.run.mock_calls), 2)
        self.assertEqual(len(warned), 1)