def test_register_fail(self, logger_mock, permission_mock, content_type_mock): content_type_mock.objects.get_or_create.side_effect = Exception error_expected = 1 res = register_permissions() self.assertEqual(logger_mock.exception.call_count, error_expected) self.assertFalse(res)
def test_register(self, logger_mock, permission_mock, content_type_mock): content_type_mock.objects.get_or_create.return_value = (None, False) permission_mock.objects.get_or_create.return_value = (None, False) warn_expected = 1 + len(AUDIT_PERMISSIONS) res = register_permissions() self.assertEqual(logger_mock.warn.call_count, warn_expected) self.assertTrue(res)
def test_register_registered_yet(self, logger_mock, permission_mock, content_type_mock): content_type_mock.objects.get_or_create.return_value = (None, True) permission_mock.objects.get_or_create.return_value = (None, True) warn_expected = 0 res = register_permissions() self.assertEqual(logger_mock.warn.call_count, warn_expected) self.assertTrue(res)
def do_prepare_audit(): """ Include steps to prepare audit. Usable from migrations """ register_permissions()