def sync_audit(map, counter): """Run resync audit.""" client = Client() # ignore fail to continue running, log later client.ignore_failures = True client.set_mappings(map) # init_logging(verbose=True) src_resource_list = client.find_resource_list() rlb = ResourceListBuilder(mapper=client.mapper) dst_resource_list = rlb.from_disk() # Compare these resource lists respecting any comparison options (same, updated, deleted, created) = dst_resource_list.compare(src_resource_list) result = dict(created=[], updated=[], deleted=[]) for item in created: record_id = item.uri.rsplit('/', 1)[1] result['created'].append(record_id) for item in updated: record_id = item.uri.rsplit('/', 1)[1] result['updated'].append(record_id) for item in deleted: record_id = item.uri.rsplit('/', 1)[1] result['deleted'].append(record_id) update_counter(counter, result) return dict(same=len(same), updated=len(updated), deleted=len(deleted), created=len(created))
def test05_find_resource_list(self): c = Client() # Filesystem tests c.set_mappings(['tests/testdata/find/find1', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find1') c.set_mappings(['tests/testdata/find/find2', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find2') c.set_mappings(['tests/testdata/find/find3', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find3') # Tests requiring a server with webserver('tests/testdata/find', 'localhost', 9999): c.set_mappings(['http://localhost:9999/find1', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find1') c.set_mappings(['http://localhost:9999/find2', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find2') c.set_mappings(['http://localhost:9999/find3', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find3') with webserver('tests/testdata/find/find1', 'localhost', 9999): c.set_mappings(['http://localhost:9999/data', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find1') with webserver('tests/testdata/find/find3', 'localhost', 9999): c.set_mappings(['http://localhost:9999/data/data1', 'xxx']) self.assertEqual(c.find_resource_list().up, 'find3')