Coverage for tests/test_htcondor_service.py: 58%
12 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-02 10:11 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-02 10:11 +0000
1# This file is part of ctrl_bps_htcondor.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This software is dual licensed under the GNU General Public License and also
10# under a 3-clause BSD license. Recipients may choose which of these licenses
11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
12# respectively. If you choose the GPL option then the following text applies
13# (but note that there is still no warranty even if you opt for BSD instead):
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <https://www.gnu.org/licenses/>.
27import unittest
29import htcondor
30from lsst.ctrl.bps.htcondor.htcondor_service import _get_exit_code_summary
33class TestGetExitCodeSummary(unittest.TestCase):
34 """Unit tests for function responsible for creating exit code summary."""
36 def setUp(self):
37 self.jobs = {
38 "1.0": {
39 "JobStatus": htcondor.JobStatus.IDLE,
40 "bps_job_label": "foo",
41 },
42 "2.0": {
43 "JobStatus": htcondor.JobStatus.RUNNING,
44 "bps_job_label": "foo",
45 },
46 "3.0": {
47 "JobStatus": htcondor.JobStatus.REMOVED,
48 "bps_job_label": "foo",
49 },
50 "4.0": {
51 "ExitCode": 0,
52 "ExitBySignal": False,
53 "JobStatus": htcondor.JobStatus.COMPLETED,
54 "bps_job_label": "bar",
55 },
56 "5.0": {
57 "ExitCode": 1,
58 "ExitBySignal": False,
59 "JobStatus": htcondor.JobStatus.COMPLETED,
60 "bps_job_label": "bar",
61 },
62 "6.0": {
63 "ExitBySignal": True,
64 "ExitSignal": 11,
65 "JobStatus": htcondor.JobStatus.HELD,
66 "bps_job_label": "baz",
67 },
68 "7.0": {
69 "ExitBySignal": False,
70 "HoldReasonCode": 42,
71 "JobStatus": htcondor.JobStatus.HELD,
72 "bps_job_label": "baz",
73 },
74 "8.0": {
75 "JobStatus": htcondor.JobStatus.TRANSFERRING_OUTPUT,
76 "bps_job_label": "qux",
77 },
78 "9.0": {
79 "JobStatus": htcondor.JobStatus.SUSPENDED,
80 "bps_job_label": "qux",
81 },
82 }
84 def tearDown(self):
85 pass
87 def test(self):
88 actual = _get_exit_code_summary(self.jobs)
89 expected = {"foo": [], "bar": [1], "baz": [11, 42], "qux": []}
90 self.assertEqual(actual, expected)