def test_communication_preference_autocreation(self): """ When new users register, CommunicationPreferences should be automatically created . """ # Create a user user = UserFactory(username='******', password='******', email='*****@*****.**') # There should be no preferences yet self.assertFalse(CommunicationPreference.objects.filter( worker__user=user).exists()) # Fake registering the user orchestra_user_registered.send( sender=self.__class__, user=user, request=None) # Expect the worker object to be created self.assertTrue( CommunicationPreference.objects.filter(worker__user=user).exists(), 'CommunicationPreference not autocreated on User registration' ) comm_prefs = CommunicationPreference.objects.filter(worker__user=user) self.assertEqual(comm_prefs.count(), len( CommunicationPreference.CommunicationType.choices())) for comm_pref in comm_prefs: for label, flag in comm_pref.methods.iteritems(): self.assertTrue(flag)
def test_worker_autocreation(self): """ When new users register, worker objects should be autocreated. """ # Create a user user = UserFactory(username='******', password='******', email='*****@*****.**') # There should be no worker yet self.assertFalse(Worker.objects.filter(user=user).exists()) # Fake registering the user orchestra_user_registered.send( sender=self.__class__, user=user, request=None) # Expect the worker object to be created self.assertTrue(Worker.objects.filter(user=user).exists(), 'Worker not autocreated on User registration')
def test_worker_autocreation(self): """ When new users register, worker objects should be autocreated. """ # Create a user user = UserFactory(username='******', password='******', email='*****@*****.**') # There should be no worker yet self.assertFalse(Worker.objects.filter(user=user).exists()) # Fake registering the user orchestra_user_registered.send(sender=self.__class__, user=user, request=None) # Expect the worker object to be created self.assertTrue( Worker.objects.filter(user=user).exists(), 'Worker not autocreated on User registration')