def handle_build(commit_hash, image_name): """ ensure the api represents that the image was built from the commit The iteration gets it's build name updated and releases are created for the branch's automatic pipelines. The branch's automatic pipelines are run. """ print("handling build ({}, {})".format(commit_hash, image_name,)) iteration = get_iteration(commit_hash=commit_hash) set_iteration(iteration['iteration_id'], {'image_name': image_name}) releases = idem_release_in_automatic_pipelines(iteration['iteration_id']) print("running releases {}".format(releases)) run(releases) return {'iteration_id': iteration['iteration_id']}
def test_get_iteration_by_id(self): """ should return an iteration given an id """ # set up now = datetime.datetime.now().ctime(), mock_description = PropertyMock(return_value=(("iteration_id",),)) type(self.mock_get_cur.return_value).description = mock_description self.mock_get_cur.return_value.fetchone.return_value = (122,) # run SUT iteration = get_iteration(122) # confirm that the cursor executed reasonable sql self.mock_get_cur.return_value.execute.assert_called_once_with( "SELECT * FROM iteration WHERE iteration_id=%s", (122,), ) self.assertEqual(iteration, {"iteration_id": 122}) # confirm we closed the cursor self.mock_get_cur.return_value.close.assert_called_once_with()
def test_get_iteration_by_commit_hash(self): """ Should return an iteration when given a commit hash """ # set up now = datetime.datetime.now().ctime(), mock_description = PropertyMock(return_value=(("iteration_id",),)) type(self.mock_get_cur.return_value).description = mock_description self.mock_get_cur.return_value.fetchone.return_value = (123,) # run SUT iteration = get_iteration(commit_hash='abc123') # confirm that the cursor executed reasonable sql self.mock_get_cur.return_value.execute.assert_called_once_with( "SELECT * FROM iteration WHERE commit_hash=%s", ('abc123',), ) # confirm that the iteration returned is correct self.assertEqual(iteration, {"iteration_id": 123}) # confirm we closed the cursor self.mock_get_cur.return_value.close.assert_called_once_with()