-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add comprehensive tests for notification flow (and get these pa…
…ssing) covering product creation events, error handling, retry mechanisms, and notification cleanup. Tests verify the full lifecycle of notifications including async event processing, error callbacks, retry behavior, and automatic cleanup of expired notifications. - add missing files
- Loading branch information
1 parent
7adb288
commit f2a2238
Showing
2 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
179 changes: 179 additions & 0 deletions
179
apps/engagement/migrations/0002_appnotification_appnotificationtemplate_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
# Generated by Django 4.2.2 on 2024-11-21 15:16 | ||
|
||
import apps.engagement.models | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('talent', '0017_alter_bountyclaim_options_and_more'), | ||
('engagement', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='AppNotification', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True, null=True)), | ||
('updated_at', models.DateTimeField(auto_now=True, null=True)), | ||
('title', models.CharField(max_length=400)), | ||
('message', models.CharField(max_length=4000)), | ||
('is_read', models.BooleanField(default=False)), | ||
('read_at', models.DateTimeField(blank=True, null=True)), | ||
('delete_at', models.DateTimeField(default=apps.engagement.models.default_delete_at)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='AppNotificationTemplate', | ||
fields=[ | ||
('event_type', models.CharField(choices=[('PRODUCT_CREATED', 'Product Created')], max_length=50, primary_key=True, serialize=False)), | ||
('title_template', models.CharField(max_length=400)), | ||
('message_template', models.CharField(max_length=4000)), | ||
('permitted_params', models.CharField(max_length=500)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='EmailNotificationTemplate', | ||
fields=[ | ||
('event_type', models.CharField(choices=[('PRODUCT_CREATED', 'Product Created')], max_length=50, primary_key=True, serialize=False)), | ||
('title', models.CharField(max_length=400)), | ||
('template', models.CharField(max_length=4000)), | ||
('permitted_params', models.CharField(max_length=500)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='NotifiableEvent', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True, null=True)), | ||
('updated_at', models.DateTimeField(auto_now=True, null=True)), | ||
('event_type', models.CharField(choices=[('PRODUCT_CREATED', 'Product Created')], max_length=50)), | ||
('params', models.JSONField(default=dict)), | ||
('delete_at', models.DateTimeField(blank=True, null=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='NotificationPreference', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True, null=True)), | ||
('updated_at', models.DateTimeField(auto_now=True, null=True)), | ||
('product_notifications', models.CharField(choices=[('NONE', 'No notifications'), ('APPS', 'In-app only'), ('EMAIL', 'Email only'), ('BOTH', 'Both app and email')], default='BOTH', max_length=10)), | ||
], | ||
options={ | ||
'verbose_name_plural': 'Notification Preferences', | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name='emailnotification', | ||
name='event_type', | ||
), | ||
migrations.RemoveField( | ||
model_name='emailnotification', | ||
name='permitted_params', | ||
), | ||
migrations.RemoveField( | ||
model_name='emailnotification', | ||
name='template', | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='body', | ||
field=models.CharField(blank=True, max_length=4000, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='created_at', | ||
field=models.DateTimeField(auto_now_add=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='delete_at', | ||
field=models.DateTimeField(default=apps.engagement.models.default_delete_at), | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='id', | ||
field=models.BigAutoField(auto_created=True, default=None, primary_key=True, serialize=False, verbose_name='ID'), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='sent_at', | ||
field=models.DateTimeField(auto_now_add=True, default=None), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='updated_at', | ||
field=models.DateTimeField(auto_now=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='emailnotification', | ||
name='event', | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to='engagement.notifiableevent' | ||
), | ||
), | ||
migrations.AddIndex( | ||
model_name='emailnotification', | ||
index=models.Index(fields=['event'], name='engagement__event_i_350a65_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='emailnotification', | ||
index=models.Index(fields=['sent_at'], name='engagement__sent_at_c0c316_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='emailnotification', | ||
index=models.Index(fields=['delete_at'], name='engagement__delete__a140d4_idx'), | ||
), | ||
migrations.AddField( | ||
model_name='notificationpreference', | ||
name='person', | ||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='notification_preferences', to='talent.person'), | ||
), | ||
migrations.AddField( | ||
model_name='notifiableevent', | ||
name='person', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='talent.person'), | ||
), | ||
migrations.AddField( | ||
model_name='appnotification', | ||
name='event', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='engagement.notifiableevent'), | ||
), | ||
migrations.AddIndex( | ||
model_name='notificationpreference', | ||
index=models.Index(fields=['person'], name='engagement__person__61a8be_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='notifiableevent', | ||
index=models.Index(fields=['delete_at'], name='engagement__delete__e924b5_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='notifiableevent', | ||
index=models.Index(fields=['person'], name='engagement__person__d5d5cb_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='appnotification', | ||
index=models.Index(fields=['event'], name='engagement__event_i_5298f0_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='appnotification', | ||
index=models.Index(fields=['is_read'], name='engagement__is_read_dd8c61_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='appnotification', | ||
index=models.Index(fields=['read_at'], name='engagement__read_at_7e0f96_idx'), | ||
), | ||
migrations.AddIndex( | ||
model_name='appnotification', | ||
index=models.Index(fields=['delete_at'], name='engagement__delete__f4b139_idx'), | ||
), | ||
] |