Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
0ae75d0
Squash Merge Notification Refactor Phase 2 (#11321)
cslzchen Sep 18, 2025
5e29285
[ENG-8996] Fix moderator digest (#11319)
Ostap-Zherebetskyi Sep 18, 2025
ffa65ec
[ENG-8978] Fix issue with user confirmation/merger creating subscript…
Johnetordoff Sep 19, 2025
d24cb2c
[ENG-8995] Fix issue with no login not being sent (#11326)
Johnetordoff Sep 19, 2025
cf68080
Update v2 subscription API for Ag and new data
Johnetordoff Sep 19, 2025
caca24c
fix issues with the API backward compatibility
Johnetordoff Sep 19, 2025
7975650
Merge remote-tracking branch 'upstream/develop' into feature/notifica…
cslzchen Oct 15, 2025
6c987b9
Fix merge conflicts as a result of merge commit 7975650a11
cslzchen Oct 15, 2025
8d55887
fix template language
Johnetordoff Sep 18, 2025
cc84096
reorganize templates to deal with conditional statement better gramma…
Johnetordoff Sep 19, 2025
cce5b22
Fix templates
bodintsov Oct 16, 2025
491b828
Merge pull request #11370 from bodintsov/fix/notification-contrib-tem…
cslzchen Oct 17, 2025
469ea23
fix unit tests
Ostap-Zherebetskyi Sep 29, 2025
7969612
Turn on script tests
Ostap-Zherebetskyi Sep 29, 2025
b48fc7e
fix merge conflict issues
Ostap-Zherebetskyi Oct 17, 2025
25ac360
Merge pull request #11372 from Ostap-Zherebetskyi/fix/script_tests
cslzchen Oct 17, 2025
38d6315
fix email template mismatch
Johnetordoff Sep 19, 2025
fd453ec
Merge pull request #11328 from Johnetordoff/fix-moderator-added-template
cslzchen Oct 17, 2025
0b7fe79
Merge pull request #11329 from Johnetordoff/fix/update-v2-subscriptions
Johnetordoff Oct 22, 2025
e477dcd
fix merge conflicts for unregistered contributors
Johnetordoff Oct 22, 2025
0766a7e
remove assertions
Ostap-Zherebetskyi Oct 23, 2025
b2440ac
Merge pull request #11388 from Ostap-Zherebetskyi/fix/password_reset_…
Johnetordoff Oct 23, 2025
06f93dc
Merge branch 'feature/notification-refactor-p2-s' of https://github.c…
Johnetordoff Oct 23, 2025
b6f5305
fix institutional node request updates template
Johnetordoff Oct 23, 2025
a741876
Merge pull request #11384 from Johnetordoff/fix-test-add-contributors…
Johnetordoff Oct 23, 2025
faaf112
Merge branch 'feature/notification-refactor-p2-s' of https://github.c…
Johnetordoff Oct 23, 2025
89ae33b
Merge pull request #11389 from Johnetordoff/fix-institutional-request…
Johnetordoff Oct 23, 2025
f3aa95c
fix test_non_contributor_create_project_from_public_template_success
Ostap-Zherebetskyi Oct 23, 2025
f7d58c1
fix test_contributor_create_project_from_private_template_with_permis…
Ostap-Zherebetskyi Oct 23, 2025
9150fbe
update draft registration URL to use angular route
Ostap-Zherebetskyi Oct 24, 2025
4896055
fix unit test
Ostap-Zherebetskyi Oct 24, 2025
7794bda
Merge pull request #11392 from Ostap-Zherebetskyi/fix/ENG-9630_node_u…
Johnetordoff Oct 24, 2025
20b97ee
Merge pull request #11393 from Ostap-Zherebetskyi/fix/ENG-8988-regist…
Johnetordoff Oct 27, 2025
2e00d45
fix review comments
Ostap-Zherebetskyi Oct 28, 2025
71d98e0
update event_context key
Ostap-Zherebetskyi Oct 28, 2025
0aad687
return missing variables
Ostap-Zherebetskyi Oct 28, 2025
e421342
Merge pull request #11395 from Ostap-Zherebetskyi/fix/NR_review_comments
Johnetordoff Oct 28, 2025
9cdb472
fix filtering and file subscription creation for nodes
Johnetordoff Oct 30, 2025
b4dce11
update migration test for on demand subscription creation
Johnetordoff Oct 30, 2025
aab8aa6
filter on query instead of list
Johnetordoff Oct 30, 2025
7b09dc4
Merge pull request #11405 from Johnetordoff/fix-node-subscriptions-on…
Johnetordoff Oct 30, 2025
3ac7d7d
Add status for moderator emails that have subscription, but have mode…
Johnetordoff Oct 31, 2025
b10e1b5
remove unnecessary log statement to avoid filling up Sentry
Johnetordoff Oct 31, 2025
067fc19
add notificationdigest test to CI and standardize
Johnetordoff Oct 31, 2025
b7580b3
remove osf groups from CI, this was cause all tests on this branch to…
Johnetordoff Oct 31, 2025
6582cc1
Merge branch 'develop' of https://github.com/centerforopenscience/osf…
Johnetordoff Nov 1, 2025
f9f7027
Revert "revert push to develop"
Johnetordoff Nov 3, 2025
316b46d
Merge pull request #11415 from Johnetordoff/feature/notification-refa…
Johnetordoff Nov 3, 2025
8876684
reinstate osf groups tests and activate api_tests/notifications in CI
Johnetordoff Nov 3, 2025
eadfc33
fix reactivated and added notifications tests to work with refactor
Johnetordoff Nov 3, 2025
700180d
add context manager for mocking notifications without the any notific…
Johnetordoff Nov 3, 2025
8d7bbdf
use context argument `allow_none=True` instead of new manager.
Johnetordoff Nov 3, 2025
c83c418
fix unit tests and pull provider id from subscription instead of even…
Johnetordoff Nov 3, 2025
91634ba
Merge pull request #11416 from Johnetordoff/fix-api3-test-issues
Johnetordoff Nov 3, 2025
0b0f9ff
Merge branch 'feature/notification-refactor-p2-s' of https://github.c…
Johnetordoff Nov 3, 2025
529edc8
remove second `'api_tests/notifications', as previous PR as merged
Johnetordoff Nov 3, 2025
278efb5
remove second `'api_tests/notifications', as previous PR as merged
Johnetordoff Nov 3, 2025
795ae7d
don't change 'api_tests/notifications', in this PR
Johnetordoff Nov 3, 2025
348964c
fix api3 ci
Ostap-Zherebetskyi Nov 4, 2025
74504ad
fix api3 ci
Ostap-Zherebetskyi Nov 4, 2025
d6adb5f
Merge pull request #11419 from Ostap-Zherebetskyi/fix/api3_ci_tests
Johnetordoff Nov 4, 2025
7b198e8
Merge branch 'feature/notification-refactor-p2-s' of https://github.c…
Johnetordoff Nov 4, 2025
794b3f0
Merge pull request #11408 from Johnetordoff/fix-moderator-emails-with…
Johnetordoff Nov 4, 2025
78cffa9
redo new_public_project notifications to happen every time a contribu…
Johnetordoff Nov 4, 2025
8fb3c17
fix no login email
Ostap-Zherebetskyi Nov 5, 2025
95ba79f
make object subscribed to node
Johnetordoff Nov 5, 2025
3399481
update send_no_login_email
Ostap-Zherebetskyi Nov 5, 2025
181dfe4
Merge pull request #11423 from Ostap-Zherebetskyi/fix/no_login_email
Johnetordoff Nov 5, 2025
e3da416
Merge pull request #11421 from Johnetordoff/add-public-project-notifi…
Johnetordoff Nov 5, 2025
bfebd2e
fix issues where legacy notification subscription settings didn't mov…
Johnetordoff Nov 5, 2025
ad0ebfd
add extra fields for migration
Johnetordoff Nov 5, 2025
2a5bff0
add more statements altering tables to separate out legacy data
Johnetordoff Nov 5, 2025
3a0c583
improve migrate notifications migration and command
Johnetordoff Nov 6, 2025
e18b744
use better migration naming convention
Johnetordoff Nov 6, 2025
d3aaf14
use correct query for backfill migration
Johnetordoff Nov 6, 2025
ff29e91
fix comments for migration noties
Johnetordoff Nov 6, 2025
e3edf96
fix tests still using model relationships
Johnetordoff Nov 6, 2025
1fd26ff
add file from previous commit I forgot
Johnetordoff Nov 6, 2025
6f15188
add node subscription tests and make migration reversible by renaming…
Johnetordoff Nov 6, 2025
fcd6d29
use better more static raw SQL query for retrieving legacy data
Johnetordoff Nov 6, 2025
95a52ca
fix digest tests with new naming scheme for notifications refactor
Johnetordoff Nov 6, 2025
e33c0f6
replace bulk create for file subscriptions with `get_or_create` and a…
Johnetordoff Nov 6, 2025
d5c457a
don't create necessary subscriptions, but default to instant delivery
Johnetordoff Nov 6, 2025
0d050d2
add tests ensuring the correct subscriptions for registered and unreg…
Johnetordoff Nov 6, 2025
b1f0527
Merge pull request #11426 from Johnetordoff/fix-issue-with-duplicate-…
Johnetordoff Nov 7, 2025
04a68ad
fix migrate_legacy_notification_subscriptions
Ostap-Zherebetskyi Nov 7, 2025
9398855
Merge pull request #11424 from Johnetordoff/fix-legacy-notification-m…
Johnetordoff Nov 7, 2025
7109646
fix notification template spelling error
Johnetordoff Nov 7, 2025
d202525
fix spelling mistake in fixed mistake
Johnetordoff Nov 7, 2025
6b3b582
change url from api link to web link, though the are both called `abs…
Johnetordoff Nov 7, 2025
2ba08ad
fix password reset link
Johnetordoff Nov 7, 2025
0ab798a
Merge pull request #11428 from Johnetordoff/fix-spelling-in-template
Johnetordoff Nov 7, 2025
2086a40
add provider url
Ostap-Zherebetskyi Nov 7, 2025
9870b69
Merge pull request #11429 from Johnetordoff/fix-collection-template-link
Johnetordoff Nov 7, 2025
85b8434
Merge pull request #11430 from Johnetordoff/fix-password-reset-link
Johnetordoff Nov 7, 2025
a021957
Merge pull request #11431 from Ostap-Zherebetskyi/fix/moderator_added…
Johnetordoff Nov 7, 2025
f8961b5
fix TestNotificationSubscriptionMigration
Ostap-Zherebetskyi Nov 7, 2025
7741716
Merge pull request #11432 from Ostap-Zherebetskyi/fix/migrate_legacy_…
Johnetordoff Nov 7, 2025
218ee4e
check if node has provider and moderator groups
Johnetordoff Nov 12, 2025
aa77110
fix API links for collection submissions
Johnetordoff Nov 12, 2025
ccc2314
update tests for correct subscribed object behavior
Johnetordoff Nov 12, 2025
9668206
add subscribed object for sanctions
Johnetordoff Nov 12, 2025
c6aa7ee
ensure sanctions have a subscribed object
Johnetordoff Nov 12, 2025
0561e13
add event name for provider notifications and use preprintprovider on…
Johnetordoff Nov 13, 2025
5d258cd
Merge pull request #11441 from Johnetordoff/fix-patching-notification…
Johnetordoff Nov 13, 2025
16833e8
Merge pull request #11439 from Johnetordoff/fix-for-nodes-without-mod…
Johnetordoff Nov 13, 2025
e9703be
fix provider_url passed into template as tuple
Ostap-Zherebetskyi Nov 17, 2025
b7aaf01
add provider_url in confirmation email template
Ostap-Zherebetskyi Nov 17, 2025
b45c8b8
Merge pull request #11448 from Ostap-Zherebetskyi/fix/provider_url_tuple
cslzchen Nov 17, 2025
a53a91e
fix notifications logo
Ostap-Zherebetskyi Nov 13, 2025
ff216dd
Merge pull request #11442 from Ostap-Zherebetskyi/fix/template_logo
cslzchen Nov 17, 2025
c1c9be6
Revert "Revert "push to develop""
cslzchen Nov 18, 2025
e3c84ff
use server dependent domain instead of hard-coded production URL
Ostap-Zherebetskyi Nov 18, 2025
38326bb
add domain to USER_FILE_OPERATION event_context
Ostap-Zherebetskyi Nov 18, 2025
9f8541b
fix digest tests
Ostap-Zherebetskyi Nov 18, 2025
16a9375
update notification settings URL and provider URL based on provider type
Ostap-Zherebetskyi Nov 18, 2025
3971926
fix: update logo image paths to use static directory
Ostap-Zherebetskyi Nov 19, 2025
9ad2947
update claim URLs to use legacy path in test cases
Ostap-Zherebetskyi Nov 19, 2025
deac425
update SubscriptionDetail APIView
Ostap-Zherebetskyi Nov 19, 2025
c50d126
Merge pull request #11450 from Ostap-Zherebetskyi/fix/hardcoded_logo_url
cslzchen Nov 19, 2025
f427102
fix unit tests
Ostap-Zherebetskyi Nov 20, 2025
f01229b
fix unit tests
Ostap-Zherebetskyi Nov 20, 2025
7260fec
update notification_settings_url
Ostap-Zherebetskyi Nov 20, 2025
40555a8
Merge pull request #11451 from Ostap-Zherebetskyi/fix/update_provider…
cslzchen Nov 20, 2025
82ab217
Merge pull request #11440 from Johnetordoff/fix-collection-submission…
cslzchen Nov 20, 2025
32dac1f
Merge pull request #11454 from Ostap-Zherebetskyi/fix/notification_se…
cslzchen Nov 20, 2025
f9a6f03
Merge pull request #11449 from CenterForOpenScience/revert-11415-feat…
cslzchen Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 28 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,31 @@ jobs:
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report

scripts:
runs-on: ubuntu-22.04
permissions:
checks: write
needs: build-cache
services:
postgres:
image: postgres

env:
POSTGRES_PASSWORD: ${{ env.OSF_DB_PASSWORD }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/start-build
- name: Run tests
run: poetry run python3 -m invoke test-ci-scripts -n 1 --junit
- name: Upload report
if: (github.event_name != 'pull_request') && (success() || failure()) # run this step even if previous step failed
uses: ./.github/actions/gen-report
47 changes: 27 additions & 20 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from framework.flask import redirect
from framework.sentry import log_exception
from framework.transactions.handlers import no_auto_transaction
from website import mails
from website import settings
from addons.base import signals as file_signals
from addons.base.utils import format_last_known_metadata, get_mfr_url
Expand All @@ -52,7 +51,7 @@
DraftRegistration,
Guid,
FileVersionUserMetadata,
FileVersion
FileVersion, NotificationType
)
from osf.metrics import PreprintView, PreprintDownload
from osf.utils import permissions
Expand All @@ -64,7 +63,7 @@
from website.util import rubeus

# import so that associated listener is instantiated and gets emails
from website.notifications.events.files import FileEvent # noqa
from notifications.file_event_notifications import FileEvent # noqa

ERROR_MESSAGES = {'FILE_GONE': """
<style>
Expand Down Expand Up @@ -226,8 +225,6 @@ def get_auth(auth, **kwargs):
_check_resource_permissions(resource, auth, action)

provider_name = waterbutler_data['provider']
waterbutler_settings = None
waterbutler_credentials = None
file_version = file_node = None
if provider_name == 'osfstorage' or (not flag_is_active(request, features.ENABLE_GV)):
file_version, file_node = _get_osfstorage_file_version_and_node(
Expand Down Expand Up @@ -576,20 +573,32 @@ def create_waterbutler_log(payload, **kwargs):
params=payload
)

if payload.get('email') is True or payload.get('errors'):
mails.send_mail(
user.username,
mails.FILE_OPERATION_FAILED if payload.get('errors')
else mails.FILE_OPERATION_SUCCESS,
action=payload['action'],
source_node=source_node,
destination_node=destination_node,
source_path=payload['source']['materialized'],
source_addon=payload['source']['addon'],
destination_addon=payload['destination']['addon'],
osf_support_email=settings.OSF_SUPPORT_EMAIL
if payload.get('email') or payload.get('errors'):
if payload.get('email'):
notification_type = NotificationType.Type.USER_FILE_OPERATION_SUCCESS.instance
if payload.get('errors'):
notification_type = NotificationType.Type.USER_FILE_OPERATION_FAILED.instance
notification_type.emit(
user=user,
subscribed_object=node,
event_context={
'user_fullname': user.fullname,
'action': payload['action'],
'source_node': source_node._id,
'source_node_title': source_node.title,
'destination_node': destination_node._id,
'destination_node_title': destination_node.title,
'destination_node_parent_node_title': destination_node.parent_node.title if destination_node.parent_node else None,
'source_path': payload['source']['materialized'],
'source_addon': payload['source']['addon'],
'destination_addon': payload['destination']['addon'],
'osf_support_email': settings.OSF_SUPPORT_EMAIL,
'logo': settings.OSF_LOGO,
'OSF_LOGO_LIST': settings.OSF_LOGO_LIST,
'OSF_LOGO': settings.OSF_LOGO,
'domain': settings.DOMAIN,
}
)

if payload.get('errors'):
# Action failed but our function succeeded
# Bail out to avoid file_signals
Expand All @@ -603,10 +612,8 @@ def create_waterbutler_log(payload, **kwargs):
target_node = AbstractNode.load(metadata.get('nid'))
if target_node and payload['action'] != 'download_file':
update_storage_usage_with_size(payload)

with transaction.atomic():
file_signals.file_updated.send(target=node, user=user, event_type=action, payload=payload)

return {'status': 'success'}


Expand Down
64 changes: 33 additions & 31 deletions addons/boa/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
from addons.boa.boa_error_code import BoaErrorCode
from framework import sentry
from framework.celery_tasks import app as celery_app
from osf.models import OSFUser
from osf.models import OSFUser, NotificationType
from osf.utils.fields import ensure_str, ensure_bytes
from website import settings as osf_settings
from website.mails import send_mail, ADDONS_BOA_JOB_COMPLETE, ADDONS_BOA_JOB_FAILURE

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -184,18 +183,19 @@ async def submit_to_boa_async(host, username, password, user_guid, project_guid,

logger.info('Successfully uploaded query output to OSF.')
logger.debug('Task ends <<<<<<<<')
await sync_to_async(send_mail)(
to_addr=user.username,
mail=ADDONS_BOA_JOB_COMPLETE,
fullname=user.fullname,
query_file_name=query_file_name,
query_file_full_path=file_full_path,
output_file_name=output_file_name,
job_id=boa_job.id,
project_url=project_url,
boa_job_list_url=boa_settings.BOA_JOB_LIST_URL,
boa_support_email=boa_settings.BOA_SUPPORT_EMAIL,
osf_support_email=osf_settings.OSF_SUPPORT_EMAIL,
NotificationType.Type.ADDONS_BOA_JOB_COMPLETE.instance.emit(
user=user,
event_context={
'user_fullname': user.fullname,
'query_file_name': query_file_name,
'query_file_full_path': file_full_path,
'output_file_name': output_file_name,
'job_id': boa_job.id,
'project_url': project_url,
'boa_job_list_url': boa_settings.BOA_JOB_LIST_URL,
'boa_support_email': boa_settings.BOA_SUPPORT_EMAIL,
'osf_support_email': osf_settings.OSF_SUPPORT_EMAIL,
}
)
return BoaErrorCode.NO_ERROR

Expand All @@ -209,22 +209,24 @@ def handle_boa_error(message, code, username, fullname, project_url, query_file_
sentry.log_message(message, skip_session=True)
except Exception:
pass
send_mail(
to_addr=username,
mail=ADDONS_BOA_JOB_FAILURE,
fullname=fullname,
code=code,
message=message,
query_file_name=query_file_name,
file_size=file_size,
max_file_size=boa_settings.MAX_SUBMISSION_SIZE,
query_file_full_path=query_file_full_path,
output_file_name=output_file_name,
job_id=job_id,
max_job_wait_hours=boa_settings.MAX_JOB_WAITING_TIME / 3600,
project_url=project_url,
boa_job_list_url=boa_settings.BOA_JOB_LIST_URL,
boa_support_email=boa_settings.BOA_SUPPORT_EMAIL,
osf_support_email=osf_settings.OSF_SUPPORT_EMAIL,
NotificationType.Type.ADDONS_BOA_JOB_FAILURE.instance.emit(
destination_address=username,
event_context={
'user_fullname': fullname,
'code': code,
'query_file_name': query_file_name,
'file_size': file_size,
'message': message,
'max_file_size': boa_settings.MAX_SUBMISSION_SIZE,
'query_file_full_path': query_file_full_path,
'output_file_name': output_file_name,
'job_id': job_id,
'max_job_wait_hours': boa_settings.MAX_JOB_WAITING_TIME / 3600,
'project_url': project_url,
'boa_job_list_url': boa_settings.BOA_JOB_LIST_URL,
'boa_support_email': boa_settings.BOA_SUPPORT_EMAIL,
'osf_support_email': osf_settings.OSF_SUPPORT_EMAIL,

}
)
return code
57 changes: 21 additions & 36 deletions addons/boa/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
from addons.boa import settings as boa_settings
from addons.boa.boa_error_code import BoaErrorCode
from addons.boa.tasks import submit_to_boa, submit_to_boa_async, handle_boa_error
from osf.models import NotificationType
from osf_tests.factories import AuthUserFactory, ProjectFactory
from tests.base import OsfTestCase
from tests.utils import capture_notifications
from website import settings as osf_settings
from website.mails import ADDONS_BOA_JOB_COMPLETE, ADDONS_BOA_JOB_FAILURE

DEFAULT_REFRESH_JOB_INTERVAL = boa_settings.REFRESH_JOB_INTERVAL
DEFAULT_MAX_JOB_WAITING_TIME = boa_settings.MAX_JOB_WAITING_TIME
Expand All @@ -38,12 +39,6 @@ def setUp(self):
self.output_file_name = 'fake_boa_script_results.txt'
self.job_id = '1a2b3c4d5e6f7g8'

from conftest import start_mock_send_grid
self.mock_send_grid = start_mock_send_grid(self)

def tearDown(self):
super().tearDown()

def test_boa_error_code(self):
assert BoaErrorCode.NO_ERROR == -1
assert BoaErrorCode.UNKNOWN == 0
Expand All @@ -55,27 +50,26 @@ def test_boa_error_code(self):
assert BoaErrorCode.FILE_TOO_LARGE_ERROR == 6
assert BoaErrorCode.JOB_TIME_OUT_ERROR == 7

@mock.patch('website.mails.settings.USE_EMAIL', True)
@mock.patch('website.mails.settings.USE_CELERY', False)
def test_handle_boa_error(self):
with mock.patch('addons.boa.tasks.sentry.log_message', return_value=None) as mock_sentry_log_message, \
mock.patch('addons.boa.tasks.logger.error', return_value=None) as mock_logger_error:
return_value = handle_boa_error(
self.error_message,
BoaErrorCode.UNKNOWN,
self.user_username,
self.user_fullname,
self.project_url,
self.file_full_path,
query_file_name=self.query_file_name,
file_size=self.file_size,
output_file_name=self.output_file_name,
job_id=self.job_id
)
self.mock_send_grid.assert_called()
mock_sentry_log_message.assert_called_with(self.error_message, skip_session=True)
mock_logger_error.assert_called_with(self.error_message)
assert return_value == BoaErrorCode.UNKNOWN
with mock.patch('addons.boa.tasks.sentry.log_message', return_value=None) as mock_sentry_log_message:
with mock.patch('addons.boa.tasks.logger.error', return_value=None) as mock_logger_error:
with capture_notifications() as notifications:
return_value = handle_boa_error(
self.error_message,
BoaErrorCode.UNKNOWN,
self.user_username,
self.user_fullname,
self.project_url,
self.file_full_path,
file_size=self.file_size,
output_file_name=self.output_file_name,
job_id=self.job_id
)
assert len(notifications['emits']) == 1
assert notifications['emits'][0]['type'] == NotificationType.Type.ADDONS_BOA_JOB_FAILURE
mock_sentry_log_message.assert_called_with(self.error_message, skip_session=True)
mock_logger_error.assert_called_with(self.error_message)
assert return_value == BoaErrorCode.UNKNOWN


class TestSubmitToBoa(OsfTestCase):
Expand Down Expand Up @@ -154,14 +148,6 @@ def setUp(self):
boa_settings.REFRESH_JOB_INTERVAL = DEFAULT_REFRESH_JOB_INTERVAL
boa_settings.MAX_JOB_WAITING_TIME = DEFAULT_MAX_JOB_WAITING_TIME

from conftest import start_mock_send_grid
self.mock_send_grid = start_mock_send_grid(self)

def tearDown(self):
super().tearDown()

@mock.patch('website.mails.settings.USE_EMAIL', True)
@mock.patch('website.mails.settings.USE_CELERY', False)
async def test_submit_success(self):
with mock.patch('osf.models.user.OSFUser.objects.get', return_value=self.user), \
mock.patch('osf.models.user.OSFUser.get_or_create_cookie', return_value=self.user_cookie), \
Expand Down Expand Up @@ -190,7 +176,6 @@ async def test_submit_success(self):
assert self.mock_job.refresh.call_count == 4
assert mock_async_sleep.call_count == 4
mock_close.assert_called()
self.mock_send_grid.assert_called()
mock_handle_boa_error.assert_not_called()

async def test_download_error(self):
Expand Down
12 changes: 9 additions & 3 deletions addons/osfstorage/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from framework.auth import Auth
from addons.osfstorage.models import OsfStorageFile, OsfStorageFileNode, OsfStorageFolder
from osf.models import BaseFileNode
from osf.models import BaseFileNode, NotificationType
from osf.exceptions import ValidationError
from osf.utils.permissions import WRITE, ADMIN

Expand All @@ -24,6 +24,7 @@
from osf import models
from addons.osfstorage import utils
from addons.osfstorage import settings
from tests.utils import capture_notifications
from website.files.exceptions import FileNodeCheckedOutError, FileNodeIsPrimaryFile

SessionStore = import_module(django_conf_settings.SESSION_ENGINE).SessionStore
Expand Down Expand Up @@ -745,7 +746,11 @@ def test_after_fork_copies_versions(self, node, node_settings, auth_obj):
version = factories.FileVersionFactory()
record.add_version(version)

fork = node.fork_node(auth_obj)
with capture_notifications() as notifications:
fork = node.fork_node(auth_obj)

assert len(notifications['emits']) == 1
assert notifications['emits'][0]['type'] == NotificationType.Type.NODE_CONTRIBUTOR_ADDED_DEFAULT
fork_node_settings = fork.get_addon('osfstorage')
fork_node_settings.reload()

Expand All @@ -757,7 +762,8 @@ def test_fork_reverts_to_node_storage_region(self, user2, region, region2, node,
"""
Despite different user regions defaults, the forked node always stay in the same region as it's orginal node.
"""
fork = node.fork_node(Auth(user2))
with capture_notifications():
fork = node.fork_node(Auth(user2))
assert fork.get_addon('osfstorage').region_id == region.id

# don't inherit or override region
Expand Down
7 changes: 5 additions & 2 deletions addons/wiki/tests/test_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from framework.auth import Auth
from django.utils import timezone
from addons.wiki.utils import to_mongo_key
from tests.utils import capture_notifications

from .config import EXAMPLE_DOCS, EXAMPLE_OPS

Expand Down Expand Up @@ -818,7 +819,8 @@ def test_uuids_differ_between_forks(self):
assert project_res.status_code == 200
self.project.reload()

fork = self.project.fork_node(Auth(self.user))
with capture_notifications():
fork = self.project.fork_node(Auth(self.user))
assert fork.is_fork_of(self.project)
fork_url = fork.web_url_for('project_wiki_view', wname=self.wname)
fork_res = self.app.get(fork_url, auth=self.user.auth)
Expand Down Expand Up @@ -1084,7 +1086,8 @@ def test_get_sharejs_uuid(self):
# Differs across projects and forks
project = ProjectFactory()
assert sharejs_uuid != get_sharejs_uuid(project, wname)
fork = self.project.fork_node(Auth(self.project.creator))
with capture_notifications():
fork = self.project.fork_node(Auth(self.project.creator))
assert sharejs_uuid != get_sharejs_uuid(fork, wname)

def test_generate_share_uuid(self):
Expand Down
12 changes: 1 addition & 11 deletions admin/common_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.contrib.auth import login, REDIRECT_FIELD_NAME, authenticate, logout

from osf.models.user import OSFUser
from osf.models import AdminProfile, AbstractProvider
from osf.models import AdminProfile
from admin.common_auth.forms import LoginForm, UserRegistrationForm, DeskUserForm


Expand Down Expand Up @@ -69,16 +69,6 @@ def form_valid(self, form):

# create AdminProfile for this new user
profile, created = AdminProfile.objects.get_or_create(user=osf_user)

for group in form.cleaned_data.get('group_perms'):
osf_user.groups.add(group)
split = group.name.split('_')
group_type = split[0]
if group_type == 'reviews':
provider_id = split[2]
provider = AbstractProvider.objects.get(id=provider_id)
provider.notification_subscriptions.get(event_name='new_pending_submissions').add_user_to_subscription(osf_user, 'email_transactional')

osf_user.save()

if created:
Expand Down
Loading