Пример #1
0
 def testSkipUploadArtifacts(self):
     """Do not upload artifacts dir if it doesn't exist."""
     paths = FakePath()
     gsutil = FakeGSUtil()
     local_artifacts = None
     build = 123
     version = 'v1.terrible'
     success = True
     with Stub(os.path, 'isdir', lambda _: False):
         with Stub(bootstrap.GSUtil, 'upload_artifacts', Bomb):
             bootstrap.finish(gsutil, paths, success, local_artifacts,
                              build, version, REPO)
Пример #2
0
 def testSkipUploadArtifacts(self):
     """Do not upload artifacts dir if it doesn't exist."""
     paths = FakePath()
     gsutil = FakeGSUtil()
     local_artifacts = None
     build = 123
     version = 'v1.terrible'
     success = True
     with Stub(os.path, 'isdir', lambda _: False):
         with Stub(bootstrap.GSUtil, 'upload_artifacts', Bomb):
             bootstrap.finish(
                 gsutil, paths, success, local_artifacts,
                 build, version, REPO)
Пример #3
0
 def CheckMetadataVersion(self, key):
     gsutil = FakeGSUtil()
     paths = FakePath()
     success = True
     artifacts = 'not-a-dir'
     no_version = ''
     version = 'found it'
     with Stub(bootstrap, 'metadata', lambda *a: {key: version}):
         bootstrap.finish(gsutil, paths, success, artifacts, BUILD, no_version, REPO)
     calls = gsutil.jsons[-1]
     # Meta is second positional argument
     self.assertEquals(version, calls[0][1].get('job-version'))
     self.assertEquals(version, calls[0][1].get('version'))
Пример #4
0
 def testNoVersion(self):
     gsutil = FakeGSUtil()
     paths = FakePath()
     success = True
     artifacts = 'not-a-dir'
     no_version = ''
     version = 'should not have found it'
     with Stub(bootstrap, 'metadata', lambda *a: {'random-meta': version}):
         bootstrap.finish(gsutil, paths, success, artifacts, BUILD, no_version, REPO)
     bootstrap.finish(gsutil, paths, success, artifacts, BUILD, no_version, REPO)
     calls = gsutil.jsons[-1]
     # json data is second positional argument
     self.assertNotIn('job-version', calls[0][1])
     self.assertNotIn('version', calls[0][1])
     self.assertTrue(calls[0][1].get('metadata'))
Пример #5
0
 def testIgnoreError_UploadArtifacts(self):
     paths = FakePath()
     gsutil = FakeGSUtil()
     local_artifacts = None
     build = 123
     version = 'v1.terrible'
     success = True
     calls = []
     with Stub(os.path, 'isdir', lambda _: True):
         with Stub(os, 'walk', lambda d: [(True, True, True)]):
             def fake_upload(*a, **kw):
                 calls.append((a, kw))
                 raise subprocess.CalledProcessError(1, ['fakecmd'], None)
             gsutil.upload_artifacts = fake_upload
             bootstrap.finish(
                 gsutil, paths, success, local_artifacts,
                 build, version, REPO)
             self.assertTrue(calls)