-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1972 from VallariAg/fix-teuthology-kill
teuthology/kill.py: Fix "TypeError: 'NoneType' object is not iterable"
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from unittest.mock import patch | ||
|
||
from teuthology.kill import find_targets | ||
|
||
|
||
class TestFindTargets(object): | ||
""" Tests for teuthology.kill.find_targets """ | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_missing_run_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = [] | ||
run_targets = find_targets("run-name") | ||
assert run_targets == {} | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_missing_job_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = {} | ||
job_targets = find_targets("run-name", "3") | ||
assert job_targets == {} | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_missing_run_targets_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = [{"targets": None, "status": "waiting"}] | ||
run_targets = find_targets("run-name") | ||
assert run_targets == {} | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_missing_job_targets_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = {"targets": None} | ||
job_targets = find_targets("run-name", "3") | ||
assert job_targets == {} | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_run_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = [{"targets": {"node1": ""}, "status": "running"}] | ||
run_targets = find_targets("run-name") | ||
assert run_targets == {"node1": ""} | ||
m_get_jobs.return_value = [{"targets": {"node1": ""}}] | ||
run_targets = find_targets("run-name") | ||
assert run_targets == {} | ||
|
||
@patch('teuthology.kill.report.ResultsReporter.get_jobs') | ||
def test_job_find_targets(self, m_get_jobs): | ||
m_get_jobs.return_value = {"targets": {"node1": ""}} | ||
job_targets = find_targets("run-name", "3") | ||
assert job_targets == {"node1": ""} |