def test_remove_by_email(self): user = actions.login(self.STUDENT_EMAIL) actions.register(self, user.email(), course=self.COURSE) with common_utils.Namespace(self.NAMESPACE): sse = unsubscribe.SubscriptionStateEntity( key_name=user.email()) sse.is_subscribed = True sse.save() notifications.Manager.send_async( user.email(), self.ADMIN_EMAIL, 'testemail', 'Mary had a little lamb. She fed it beans and buns.', 'Pets for Mary', '{"audit_trail": "yes"}', retention_policy=notifications.RetainAll) # Finish deferred tasks so notifications subsystem would have # deleted items if it were going to. It shouldn't based on our # use of RetainAll above, but belt-and-suspenders. self.execute_all_deferred_tasks() l = list(notifications.Notification.all().run()) self.assertEquals(1, len(l)) l = list(notifications.Payload.all().run()) self.assertEquals(1, len(l)) self._unregister_and_request_data_removal(self.COURSE) self._complete_removal() with common_utils.Namespace(self.NAMESPACE): l = list(unsubscribe.SubscriptionStateEntity.all().run()) self.assertEquals(0, len(l)) l = list(notifications.Notification.all().run()) self.assertEquals(0, len(l)) l = list(notifications.Payload.all().run()) self.assertEquals(0, len(l))
def test_remove_by_email(self): user = actions.login(self.STUDENT_EMAIL) actions.register(self, user.email(), course=self.COURSE) # Get IDs of those students; make an event for each. with common_utils.Namespace(self.NAMESPACE): sse = unsubscribe.SubscriptionStateEntity(key_name=user.email()) sse.save() self._unregister_and_request_data_removal(self.COURSE) self._complete_removal() with common_utils.Namespace(self.NAMESPACE): l = list(unsubscribe.SubscriptionStateEntity.all().run()) self.assertEquals(0, len(l))
def test_remove_by_email(self): user = self.make_test_user(self.STUDENT_EMAIL) actions.login(user.email()) actions.register(self, user.email(), course=self.COURSE) # Get IDs of those students; make an event for each. with common_utils.Namespace(self.NAMESPACE): sse = unsubscribe.SubscriptionStateEntity(key_name=user.email()) sse.save() actions.unregister(self, self.COURSE, do_data_removal=True) self.execute_all_deferred_tasks( models.StudentLifecycleObserver.QUEUE_NAME) self.get(data_removal.DataRemovalCronHandler.URL, headers={'X-AppEngine-Cron': 'True'}) self.execute_all_deferred_tasks() with common_utils.Namespace(self.NAMESPACE): l = list(unsubscribe.SubscriptionStateEntity.all().run()) self.assertEquals(0, len(l))
def test_subscription_state_entity_must_have_key_name(self): with self.assertRaises(db.BadValueError): unsubscribe.SubscriptionStateEntity() with self.assertRaises(db.BadValueError): unsubscribe.SubscriptionStateEntity(id='23')