@pytest.mark.django_db
def test_delete_mark_obsolete_resurrect_sync(project0_nongnu, subdir0):
 store = subdir0.child_stores.first()
 store.sync()
 tp = store.translation_project
 dir_pootle_path = store.parent.pootle_path
 store_pootle_path = store.pootle_path
 for _store in tp.stores.all():
  _store.sync()
 os.remove(store.file.path)
 shutil.rmtree(os.path.dirname(store.file.path))
 tp.scan_files()
 updated_directory = Directory.objects.get(pootle_path=dir_pootle_path)
 assert updated_directory.obsolete
 updated_store = Store.objects.get(pootle_path=store_pootle_path)
 assert updated_store.obsolete
 store_units = Unit.objects.filter(store=updated_store)
 for unit in store_units:
  assert unit.isobsolete()
 updated_directory.obsolete = False
 updated_directory.save()
 updated_store.obsolete = False
 updated_store.save()
 for unit in store_units:
  unit.resurrect()
  unit.save()
 updated_store.sync(only_newer=False)
 assert os.path.exists(updated_store.file.path)

@ pytest . mark . django_db def test_delete_mark_obsolete_resurrect_sync ( project0_nongnu , subdir0 ) : store = subdir0 . child_stores . first ( ) store . sync ( ) tp = store . translation_project dir_pootle_path = store . parent . pootle_path store_pootle_path = store . pootle_path for _store in tp . stores . all ( ) : _store . sync ( ) os . remove ( store . file . path ) shutil . rmtree ( os . path . dirname ( store . file . path ) ) tp . scan_files ( ) updated_directory = Directory . objects . get ( pootle_path = dir_pootle_path ) assert updated_directory . obsolete updated_store = Store . objects . get ( pootle_path = store_pootle_path ) assert updated_store . obsolete store_units = Unit . objects . filter ( store = updated_store ) for unit in store_units : assert unit . isobsolete ( ) updated_directory . obsolete = False updated_directory . save ( ) updated_store . obsolete = False updated_store . save ( ) for unit in store_units : unit . resurrect ( ) unit . save ( ) updated_store . sync ( only_newer = False ) assert os . path . exists ( updated_store . file . path )
tests that the in-db directory are marked as obsolete after the on-disk file ceased to exist and that the on-disk file and directory are recovered after syncing .