summaryrefslogtreecommitdiff
path: root/tko
diff options
context:
space:
mode:
Diffstat (limited to 'tko')
-rw-r--r--tko/parsers/version_0.py2
-rw-r--r--tko/parsers/version_0_unittest.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/tko/parsers/version_0.py b/tko/parsers/version_0.py
index f83c479c..1018b080 100644
--- a/tko/parsers/version_0.py
+++ b/tko/parsers/version_0.py
@@ -24,7 +24,7 @@ class job(models.job):
label = keyval.get("label", None)
host_group_name = keyval.get("host_group_name", None)
machine = keyval.get("hostname", None)
- if machine and "," in machine:
+ if not host_group_name and machine and "," in machine:
try:
machine = job.find_hostname(dir) # find a unique hostname
except NoHostnameError:
diff --git a/tko/parsers/version_0_unittest.py b/tko/parsers/version_0_unittest.py
index 884989a6..8c076ff7 100644
--- a/tko/parsers/version_0_unittest.py
+++ b/tko/parsers/version_0_unittest.py
@@ -12,10 +12,13 @@ class test_job_load_from_dir(unittest.TestCase):
def setUp(self):
self.god = mock.mock_god()
self.god.stub_function(models.job, 'read_keyval')
+ self.god.stub_function(version_0.job, 'find_hostname')
+
def tearDown(self):
self.god.unstub_all()
+
keyval_return = {'job_queued': 1234567890,
'job_started': 1234567891,
'job_finished': 1234567892,
@@ -23,6 +26,7 @@ class test_job_load_from_dir(unittest.TestCase):
'label': 'steeltown',
'hostname': 'abc123'}
+
def test_load_from_dir_simple(self):
models.job.read_keyval.expect_call('.').and_return(
dict(self.keyval_return))
@@ -32,6 +36,24 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('abc123', job['machine'])
self.god.check_playback()
+
+ def test_load_from_dir_two_machine(self):
+ raw_keyval = dict(self.keyval_return)
+ raw_keyval['hostname'] = 'easyas,abc123'
+ models.job.read_keyval.expect_call('.').and_return(raw_keyval)
+ version_0.job.find_hostname.expect_call('.').and_raises(
+ version_0.NoHostnameError('find_hostname stubbed out'))
+ job = version_0.job.load_from_dir('.')
+ self.assertEqual('easyas,abc123', job['machine'])
+
+ models.job.read_keyval.expect_call('.').and_return(raw_keyval)
+ version_0.job.find_hostname.expect_call('.').and_return('foo')
+ job = version_0.job.load_from_dir('.')
+ self.assertEqual('foo', job['machine'])
+
+ self.god.check_playback()
+
+
def test_load_from_dir_one_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
raw_keyval['host_group_name'] = 'jackson five'
@@ -41,6 +63,7 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('abc123', job['machine'])
self.god.check_playback()
+
def test_load_from_dir_multi_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
raw_keyval['user'] = 'michael'
@@ -54,6 +77,7 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('jackson five', job['machine'])
self.god.check_playback()
+
def test_load_from_dir_no_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
del raw_keyval['hostname']