Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: buildbot/manifest_version_unittest.py

Issue 6691047: Merge MVP script into cbuildbot. (Closed) Base URL: http://git.chromium.org/git/chromite.git@master
Patch Set: Fix up manifest_version docstrings and limited unittesting Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Unittests for manifest_version. Needs to be run inside of chroot for mox."""
8
9 import __builtin__
10 import mox
11 import os
12 import shutil
13 import sys
14 import unittest
15
16 import chromite.buildbot.manifest_version as manifest_version
17 import chromite.lib.cros_build_lib as cros_lib
18
19 class ManifestVersionTest(mox.MoxTestBase):
20
21 def setUp(self):
22 mox.MoxTestBase.setUp(self)
23
24 self.tmp_dir = '/foo'
25 self.source_repo = 'ssh://source/repo'
26 self.manifest_repo = 'ssh://manifest/repo'
27 self.board = 'board-name'
28 self.build_version='build-version'
29 self.version_file='version-file.sh'
30
31 self.working_dir = os.path.join(self.tmp_dir, 'working')
32 self.ver_manifests = os.path.basename(self.manifest_repo)
33 self.ver_manifests_dir = os.path.join(self.working_dir, 'repo')
34
35 def testUpdateStatusSuccess(self):
36 """Test if we can archive the latest results dir to Google Storage."""
37 #$TOOLS/mvp.py --build-name=$BOARD --status=pass \
38 # --build-version=$RELEASETAG
39
40
41 self.mox.StubOutWithMock(cros_lib, 'RunCommand')
42 self.mox.StubOutWithMock(os.path, 'exists')
43 self.mox.StubOutWithMock(manifest_version, 'SetStatus')
44
45 os.path.exists(self.ver_manifests_dir).AndReturn(True)
46
47 cros_lib.RunCommand(['git', 'checkout', 'master'],
48 cwd=self.ver_manifests_dir)
49
50 manifest_version.SetStatus(self.build_version,
51 'pass',
52 self.working_dir,
53 self.ver_manifests,
54 self.board)
55
56 self.mox.ReplayAll()
57
58 manifest_version.UpdateStatus(tmp_dir=self.tmp_dir,
59 manifest_repo=self.manifest_repo,
60 board=self.board,
61 build_version=self.build_version,
62 success=True,
63 retries=0)
64
65 self.mox.VerifyAll()
66
67 def testUpdateStatusFailure(self):
68 """Test if we can archive the latest results dir to Google Storage."""
69 #$TOOLS/mvp.py --build-name=$BOARD --status=pass \
70 # --build-version=$RELEASETAG
71
72
73 self.mox.StubOutWithMock(cros_lib, 'RunCommand')
74 self.mox.StubOutWithMock(os.path, 'exists')
75 self.mox.StubOutWithMock(manifest_version, 'SetStatus')
76
77 os.path.exists(self.ver_manifests_dir).AndReturn(True)
78
79 cros_lib.RunCommand(['git', 'checkout', 'master'],
80 cwd=self.ver_manifests_dir)
81
82 manifest_version.SetStatus(self.build_version,
83 'fail',
84 self.working_dir,
85 self.ver_manifests,
86 self.board)
87
88 self.mox.ReplayAll()
89
90 manifest_version.UpdateStatus(tmp_dir=self.tmp_dir,
91 manifest_repo=self.manifest_repo,
92 board=self.board,
93 build_version=self.build_version,
94 success=False,
95 retries=0)
96
97 self.mox.VerifyAll()
98
99
100 if __name__ == '__main__':
101 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698