Home | History | Annotate | Download | only in mini_installer
      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.
      4 
      5 import os
      6 
      7 import verifier
      8 
      9 
     10 class FileVerifier(verifier.Verifier):
     11   """Verifies that the current files match the expectation dictionaries."""
     12 
     13   def _VerifyExpectation(self, expectation_name, expectation,
     14                          variable_expander):
     15     """Overridden from verifier.Verifier.
     16 
     17     This method will throw an AssertionError if file state doesn't match the
     18     |expectation|.
     19 
     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)
     32