diff options
| author | 2019-10-07 20:00:34 -0700 | |
|---|---|---|
| committer | 2019-10-07 20:00:34 -0700 | |
| commit | e1148041501d733982adf51777748c8827f1bb7c (patch) | |
| tree | dcd27d0346613e8b13e2762cd432bd05fcf23d8c /tools/releasetools/test_utils.py | |
| parent | 7e49064030c7087e80f6addad61546714cab6a98 (diff) | |
releasetools: Move MockScriptWriter into test_utils.
Bug: 134525174
Test: TreeHugger
Test: lunch a target; atest --host releasetools_test releasetools_py3_test
Change-Id: I6d30f4d153d59d65227275e1d3285e30dfafd90e
Diffstat (limited to 'tools/releasetools/test_utils.py')
| -rwxr-xr-x | tools/releasetools/test_utils.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/releasetools/test_utils.py b/tools/releasetools/test_utils.py index 244567166d..e99975765b 100755 --- a/tools/releasetools/test_utils.py +++ b/tools/releasetools/test_utils.py @@ -145,6 +145,47 @@ def construct_sparse_image(chunks): return sparse_image +class MockScriptWriter(object): + """A class that mocks edify_generator.EdifyGenerator. + + It simply pushes the incoming arguments onto script stack, which is to assert + the calls to EdifyGenerator functions. + """ + + def __init__(self, enable_comments=False): + self.lines = [] + self.enable_comments = enable_comments + + def Mount(self, *args): + self.lines.append(('Mount',) + args) + + def AssertDevice(self, *args): + self.lines.append(('AssertDevice',) + args) + + def AssertOemProperty(self, *args): + self.lines.append(('AssertOemProperty',) + args) + + def AssertFingerprintOrThumbprint(self, *args): + self.lines.append(('AssertFingerprintOrThumbprint',) + args) + + def AssertSomeFingerprint(self, *args): + self.lines.append(('AssertSomeFingerprint',) + args) + + def AssertSomeThumbprint(self, *args): + self.lines.append(('AssertSomeThumbprint',) + args) + + def Comment(self, comment): + if not self.enable_comments: + return + self.lines.append('# {}'.format(comment)) + + def AppendExtra(self, extra): + self.lines.append(extra) + + def __str__(self): + return '\n'.join(self.lines) + + class ReleaseToolsTestCase(unittest.TestCase): """A common base class for all the releasetools unittests.""" |