Exemplo n.º 1
0
 def persist_stats(cls, stats, stats_fpath):
     if not stats or not stats_fpath:
         raise ValueError("You must provide both stats and stats file path for saving the stats to a file."
                      " Received stats = %s and stats fpath = %s" % (str(stats), str(stats_fpath)))
     if not os.path.isfile(stats_fpath):
         logging.info("Persisting the stats to disk")
         return utils.write_to_file(stats_fpath, stats)
     else:
         logging.info("Skipping persist_stats to disk, apparently there is a valid stats file there already.")
     return False
Exemplo n.º 2
0
 def persist_stats(cls, stats, stats_fpath):
     if not stats or not stats_fpath:
         raise ValueError(
             "You must provide both stats and stats file path for saving the stats to a file."
             " Received stats = %s and stats fpath = %s" %
             (str(stats), str(stats_fpath)))
     if not os.path.isfile(stats_fpath):
         logging.info("Persisting the stats to disk")
         return utils.write_to_file(stats_fpath, stats)
     else:
         logging.info(
             "Skipping persist_stats to disk, apparently there is a valid stats file there already."
         )
     return False
Exemplo n.º 3
0
 def test_write_from_file(self):
     with mock.patch('checks.utils.open') as mock_open:
         utils.write_to_file('blah', 'some_text')
         mock_open.assert_called_once_with('blah', 'w')
Exemplo n.º 4
0
 def test_write_from_file(self):
     with mock.patch('checks.utils.open') as mock_open:
         utils.write_to_file('blah', 'some_text')
         mock_open.assert_called_once_with('blah', 'w')