@patch('changes.models.Repository.get_vcs')
    def test_ensure_multiple_existing_build(self, get_vcs):
        get_vcs.return_value = self.get_fake_vcs()
        revision = self.create_revision(
            repository=self.project.repository,
            sha='a' * 40
        )
        source = self.create_source(self.project, revision=revision)

        # this is older and won't be returned
        self.create_build(self.project, source=source)
        build = self.create_build(self.project, source=source)
        resp = self.client.post(self.path, data={
            'sha': 'a' * 40,
            'repository': self.project.repository.url,
            'apply_project_files_trigger': '1',
            'ensure_only': '1',
        })
        assert resp.status_code == 200
        data = self.unserialize(resp)
        assert len(data) == 1
        assert data[0]['id'] == build.id.hex
        assert data[0]['project']['slug'] == self.project.slug
Tests when only a subset of the builds have been created
dataset/ETHPy150Open dropbox/changes/tests/changes/api/test_build_index.py/BuildCreateTest.test_ensure_multiple_existing_build