예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
def do_prepare_audit():
    """
    Include steps to prepare audit. Usable from migrations
    """
    register_permissions()