Esempio n. 1
0
 def test_not_unique_assos(self):
     other_manager = create_manager(
         create_member(assos=self.manager.assos_id,
                       profile=create_user("new_profile")))
     President.objects.create(manager=self.manager)
     president = President(manager=other_manager)
     with self.assertRaises(ValidationError):
         president.full_clean()
Esempio n. 2
0
 def test_perms(self):
     president = President(manager=self.manager)
     clean_and_save(president)
     user = president.user
     self.assertTrue(user.has_perm('manage_manager', president.assos_id))
     self.assertTrue(user.has_perm('delete_association',
                                   president.assos_id))
     self.assertTrue(user.has_perm('change_association',
                                   president.assos_id))
     president.delete()
     self.assertFalse(user.has_perm('manage_manager', president.assos_id))
     self.assertFalse(
         user.has_perm('delete_association', president.assos_id))
     self.assertFalse(
         user.has_perm('change_association', president.assos_id))
Esempio n. 3
0
 def test_manager_on_delete_cascade(self):
     president = President(assos_id=self.manager.assos_id,
                           user=self.manager.user)
     clean_and_save(president)
     president.manager.delete()
     with self.assertRaises(President.DoesNotExist):
         President.objects.get(pk=president.id)
Esempio n. 4
0
 def test_deleted_manager(self):
     president = President(assos_id=self.manager.assos_id,
                           user=self.manager.user)
     president.full_clean()
     self.manager.delete()
     with self.assertRaises(ValidationError):
         president.full_clean()
Esempio n. 5
0
 def test_str(self):
     president = President(manager=self.manager)
     self.assertEqual(
         president.__str__(),
         "%s from %s" % (president.user.username, president.assos_id.name))
Esempio n. 6
0
 def test_manager_id_is_none(self):
     self.manager.id = None
     president = President(manager=self.manager)
     with self.assertRaises(ValidationError):
         president.full_clean()
Esempio n. 7
0
 def test_deleted_profile(self):
     president = President(assos_id=self.manager.assos_id,
                           user=self.manager.user)
     self.manager.user.delete()
     with self.assertRaises(Manager.DoesNotExist):
         president.full_clean()
Esempio n. 8
0
 def test_no_ref_manager_profile_assos_combination(self):
     president = President(user=create_user("president"),
                           assos_id=create_association("president_assos"))
     with self.assertRaises(Manager.DoesNotExist):
         president.full_clean()
Esempio n. 9
0
 def test_not_unique_compositeonetoonefield(self):
     President.objects.create(manager=self.manager)
     president = President(manager=self.manager)
     with self.assertRaises(ValidationError):
         president.full_clean()
Esempio n. 10
0
 def test_valid_input(self):
     president = President(assos_id=self.manager.assos_id,
                           user=self.manager.user)
     self.assertTrue(isinstance(president, President))
     clean_and_save(president)
Esempio n. 11
0
 def test_null_manager(self):
     president = President(manager=None)
     with self.assertRaises(IntegrityError):  # see comment above
         president.save()
Esempio n. 12
0
 def test_null_assos(self):
     president = President(assos_id=None, user=self.manager.user)
     # If I full_clean doesnt raise ValidationError but
     # RelatedObjectDoesntExist instead
     with self.assertRaises(IntegrityError):
         president.save()
Esempio n. 13
0
 def test_null_profile(self):
     president = President(assos_id=self.manager.assos_id, user=None)
     with self.assertRaises(IntegrityError):  # see comment below
         president.save()