Skip to content

Commit

Permalink
Remove workdir from changed_result
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricky Cook committed Jul 11, 2016
1 parent de9f334 commit c5a9276
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 51 deletions.
18 changes: 3 additions & 15 deletions dockci/models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,30 +253,18 @@ def state(self):
else:
return 'queued' # TODO check if queued or queue fail

def changed_result(self, workdir=None):
def changed_result(self):
"""
Check if this job changed the result from it's ancestor. None if
there's no result yet
"""
if self.result is None:
return None

ancestor_job = self.ancestor_job
if not ancestor_job:
if not self.ancestor_job or self.ancestor_job.result is None:
return True

if ancestor_job.result is None:
if workdir is None: # Can't get a better ancestor
return True

ancestor_job = self.project.latest_job_ancestor(
workdir, self.commit, complete=True,
)

if not ancestor_job:
return True

return ancestor_job.result != self.result
return self.ancestor_job.result != self.result

@property
def job_output_details(self):
Expand Down
37 changes: 1 addition & 36 deletions tests/models/test_job_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,7 @@ def test_ancestor_complete(self,
assert job_current.changed_result() == changed


@pytest.mark.parametrize(
'prev_result,new_result,changed',
CHANGED_RESULT_PARAMS
)
def test_ancestor_incomplete(self,
mocker,
prev_result,
new_result,
changed):
job_current = Job()
job_ancestor_incomplete = Job()
job_ancestor = Job()
project = Project()

mocker.patch.object(job_ancestor_incomplete, 'result', new=None)
mocker.patch.object(
job_current, 'ancestor_job', new=job_ancestor_incomplete,
)

mocker.patch.object(job_current, 'project', new=project)
mocker.patch.object(job_current, 'commit', new='fake commit')
mocker.patch.object(job_current, 'result', new=new_result)
mocker.patch.object(job_ancestor, 'result', new=prev_result)

ancestor_mock = mocker.patch.object(
project, 'latest_job_ancestor', return_value=job_ancestor,
)

assert job_current.changed_result(workdir='fake workdir') == changed

ancestor_mock.assert_called_once_with(
'fake workdir', 'fake commit', complete=True,
)


def test_ancestor_incomplete_no_workdir(self, mocker):
def test_ancestor_incomplete(self, mocker):
job_current = Job()
job_ancestor_incomplete = Job()

Expand Down

0 comments on commit c5a9276

Please sign in to comment.