1. Update sharing role name removing purged user email
2. If sharing role has only one user association, delete it.
3. Factor out cleanup, add test.
Note: this will not work if user email has been udpated after the sharing
role was created.
Currently when uploading datasets with associated hashes, this were
only validated if `validate_hashes=True` was also passed in the
request.
This commit drops `validate_hashes` completely and always validates
hashes when they were provided.
We must use a union because when we retrieve roles with a query, we
check against:
1) role name
2) email of associated user for private roles
We factor out this select into a helper method, which we then test
extensively.
Reason: decouple user email from private role naming: emails can be
changed or redacted; user id in user-role-association + role type is
sufficient to tie a user to a private role.
The description (i.e., "this is a private role for a user" is inferrable
from the role name ("private role"), which is assigned by default.
- Do not explicitly import fixtures (a little duplication is safer/cleaner)
- Move dangerous fixture into module to prevent accidental usage from other modules
- Ensure only one database is used for all tests in module
When upgrading back to a valid revision, upgrade to head, not the
revision under test: we need the latest version of the model definition
in the database for the test to cleanup correctly.
and make sure we include the parent_hda when exporting histories.
Fixes
https://sentry.galaxyproject.org/share/issue/20ee27f675ef476588bbe8ff273eaee7/:
```
KeyError: '31e7840b5aedca43523bfcc8e2e9e56f'
File "galaxy/jobs/__init__.py", line 2039, in finish
task_wrapper = self.tool.exec_after_process(
File "galaxy/tools/__init__.py", line 3100, in exec_after_process
JobImportHistoryArchiveWrapper(self.app, job.id).cleanup_after_job()
File "galaxy/tools/imp_exp/__init__.py", line 81, in cleanup_after_job
model_store.perform_import(new_history, job=job, new_history=True)
File "galaxy/model/store/__init__.py", line 416, in perform_import
self._import_implicit_dataset_conversions(object_import_tracker)
File "galaxy/model/store/__init__.py", line 1280, in _import_implicit_dataset_conversions
idc.parent_hda = object_import_tracker.hdas_by_key[idc_attrs["parent_hda"]]
```