def test_calculate_vts_collection_hash_no_params(self): vts = Vts(storage=OrderedDict) vts.add( 'id_1', name='foo', vt_modification_time='01234', vt_params={ '0': { 'id': '0', 'name': 'timeout', 'default': '20', }, '1': { 'id': '1', 'name': 'foo_pref:', 'default': 'bar_value', }, }, ) vts.add('id_2', name='bar', vt_modification_time='56789') vts.calculate_vts_collection_hash(include_vt_params=False) vt_hash = sha256() vt_hash.update("id_101234id_256789".encode('utf-8')) hash_test = vt_hash.hexdigest() self.assertEqual(hash_test, vts.sha256_hash)
def test_calculate_vts_collection_hash_empty(self): vts = Vts() logging.Logger.debug = Mock() vts.calculate_vts_collection_hash() self.assertEqual(vts.sha256_hash, None) logging.Logger.debug.assert_called_with( # pylint: disable=no-member "Error calculating VTs collection hash. Cache is empty")
def test_calculate_vts_collection_hash(self): vts = Vts() vts.add('id_2', name='bar', vt_modification_time='56789') vts.add('id_1', name='foo', vt_modification_time='01234') vts.calculate_vts_collection_hash() h = sha256() h.update("id_101234id_256789".encode('utf-8')) hash_test = h.hexdigest() self.assertEqual(hash_test, vts.sha256_hash)