| 1 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 2 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 |
# |
| 4 |
# This program is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
import unittest |
| 18 |
|
| 19 |
from cylc.flow.job_runner_handlers.pbs_multi_cluster import ( |
| 20 |
PBSMulticlusterHandler, |
| 21 |
) |
| 22 |
|
| 23 |
|
| 24 |
def get_test_filter_poll_many_output(): |
| 25 |
return [ |
| 26 |
("header1\nheader2\n123.localhost", ["123.localhost@localhost"]), |
| 27 |
( |
| 28 |
"""header1 |
| 29 |
header2 |
| 30 |
12.localhost |
| 31 |
job123 |
| 32 |
09.jd-01.foo.bar""", |
| 33 |
[ |
| 34 |
"12.localhost@localhost", |
| 35 |
"job123", # unchanged |
| 36 |
"[email protected]", |
| 37 |
] |
| 38 |
), |
| 39 |
] |
| 40 |
|
| 41 |
|
| 42 |
def get_test_manip_job_id(): |
| 43 |
return [ |
| 44 |
("1.localhost", "1.localhost@localhost"), |
| 45 |
("10000.jd-01", "10000.jd-01@jd-01"), |
| 46 |
(" 1077 ", "1077") # unchanged |
| 47 |
] |
| 48 |
|
| 49 |
|
| 50 |
class TestPBSMultiCluster(unittest.TestCase): |
| 51 |
|
| 52 |
def test_filter_poll_many_output(self): |
| 53 |
"""Basic tests for filter_poll_many_output.""" |
| 54 |
for out, expected in get_test_filter_poll_many_output(): |
| 55 |
job_ids = PBSMulticlusterHandler.filter_poll_many_output(out) |
| 56 |
self.assertEqual(expected, job_ids) |
| 57 |
|
| 58 |
def test_manip_job_id(self): |
| 59 |
"""Basic tests for manip_job_id.""" |
| 60 |
for job_id, expected in get_test_manip_job_id(): |
| 61 |
mod_job_id = PBSMulticlusterHandler.manip_job_id(job_id) |
| 62 |
self.assertEqual(expected, mod_job_id) |
| 63 |
|
| 64 |
def test_export_handler(self): |
| 65 |
import cylc.flow.job_runner_handlers.pbs_multi_cluster as m |
| 66 |
self.assertTrue(hasattr(m, 'JOB_RUNNER_HANDLER')) |