def _clear_cai_data(session): """Clear CAI data from storage. Args: session (object): Database session. """ LOGGER.debug('Deleting Cloud Asset data from database.') count = CaiDataAccess.clear_cai_data(session) LOGGER.debug('%s assets deleted from database.', count) return None
def test_clear_cai_data(self): """Validate CAI data delete.""" self._add_resources() rows = CaiDataAccess.clear_cai_data(self.session) expected_rows = len(CAI_RESOURCE_DATA.split('\n')) self.assertEqual(expected_rows, rows) results = CaiDataAccess.iter_cai_assets( ContentTypes.resource, 'cloudresourcemanager.googleapis.com/Folder', '//cloudresourcemanager.googleapis.com/organizations/1234567890', self.session) self.assertEqual(0, len(list(results)))