OLD | NEW |
---|---|
(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 \ | |
sosa
2011/04/11 19:03:54
Remove comments lines here.
| |
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 True) | |
56 | |
57 self.mox.ReplayAll() | |
58 | |
59 manifest_version.UpdateStatus(tmp_dir=self.tmp_dir, | |
60 manifest_repo=self.manifest_repo, | |
61 board=self.board, | |
62 build_version=self.build_version, | |
63 success=True, | |
64 debug=True, | |
65 retries=0) | |
66 | |
67 self.mox.VerifyAll() | |
68 | |
69 def testUpdateStatusFailure(self): | |
70 """Test if we can archive the latest results dir to Google Storage.""" | |
71 #$TOOLS/mvp.py --build-name=$BOARD --status=pass \ | |
sosa
2011/04/11 19:03:54
Ditto
| |
72 # --build-version=$RELEASETAG | |
73 | |
74 | |
75 self.mox.StubOutWithMock(cros_lib, 'RunCommand') | |
76 self.mox.StubOutWithMock(os.path, 'exists') | |
77 self.mox.StubOutWithMock(manifest_version, 'SetStatus') | |
78 | |
79 os.path.exists(self.ver_manifests_dir).AndReturn(True) | |
80 | |
81 cros_lib.RunCommand(['git', 'checkout', 'master'], | |
82 cwd=self.ver_manifests_dir) | |
83 | |
84 manifest_version.SetStatus(self.build_version, | |
85 'fail', | |
86 self.working_dir, | |
87 self.ver_manifests, | |
88 self.board, | |
89 True) | |
90 | |
91 self.mox.ReplayAll() | |
92 | |
93 manifest_version.UpdateStatus(tmp_dir=self.tmp_dir, | |
94 manifest_repo=self.manifest_repo, | |
95 board=self.board, | |
96 build_version=self.build_version, | |
97 success=False, | |
98 debug=True, | |
99 retries=0) | |
100 | |
101 self.mox.VerifyAll() | |
102 | |
103 | |
104 if __name__ == '__main__': | |
105 unittest.main() | |
OLD | NEW |