Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / mini_installer / file_verifier.py
blob5e6244648a4c85701899b68997ce28b345f889ce
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import os
7 import verifier
10 class FileVerifier(verifier.Verifier):
11 """Verifies that the current files match the expectation dictionaries."""
13 def _VerifyExpectation(self, expectation_name, expectation,
14 variable_expander):
15 """Overridden from verifier.Verifier.
17 This method will throw an AssertionError if file state doesn't match the
18 |expectation|.
20 Args:
21 expectation_name: Path to the file being verified. It is expanded using
22 Expand.
23 expectation: A dictionary with the following key and value:
24 'exists' a boolean indicating whether the file should exist.
25 variable_expander: A VariableExpander object.
26 """
27 file_path = variable_expander.Expand(expectation_name)
28 file_exists = os.path.exists(file_path)
29 assert expectation['exists'] == file_exists, \
30 ('File %s exists' % file_path) if file_exists else \
31 ('File %s is missing' % file_path)