コード例 #1
0
ファイル: test_dispatch.py プロジェクト: uzayr/nereid
    def test_0010_test_failure_counter(self):
        context = CONTEXT.copy()
        with Transaction().start(DB_NAME, USER, context=context) as txn:
            self.setup_defaults()
            app = self.get_app()

            txn.cursor.commit()

        DatabaseOperationalError = backend.get('DatabaseOperationalError')

        @transaction_start.connect
        def incr_error_count(app):
            """
            Subscribe to the transaction_start to increment the counter
            """
            self.error_counter += 1

        CONFIG['retry'] = 4

        with app.test_client() as c:
            try:
                c.get('fail-with-transaction-error')
            except DatabaseOperationalError:
                self.assertEqual(self.error_counter, 5)
コード例 #2
0
ファイル: test_dispatch.py プロジェクト: 2cadz/nereid
    def test_0010_test_failure_counter(self):
        context = CONTEXT.copy()
        with Transaction().start(DB_NAME, USER, context=context) as txn:
            self.setup_defaults()
            app = self.get_app()

            txn.cursor.commit()

        DatabaseOperationalError = backend.get('DatabaseOperationalError')

        @transaction_start.connect
        def incr_error_count(app):
            """
            Subscribe to the transaction_start to increment the counter
            """
            self.error_counter += 1

        CONFIG['retry'] = 4

        with app.test_client() as c:
            try:
                c.get('fail-with-transaction-error')
            except DatabaseOperationalError:
                self.assertEqual(self.error_counter, 5)
コード例 #3
0
# -*- coding: utf-8 -*-
# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
        install_module
from trytond.transaction import Transaction
from trytond.exceptions import UserError

CONTEXT = CONTEXT.copy()
CONTEXT['_check_access'] = True


class ModelAccessTestCase(unittest.TestCase):
    'Test Model Access'

    def setUp(self):
        install_module('tests')
        self.model_access = POOL.get('ir.model.access')
        self.test_access = POOL.get('test.access')
        self.model = POOL.get('ir.model')
        self.group = POOL.get('res.group')

    def test0010perm_read(self):
        'Test Read Access'
        with Transaction().start(DB_NAME, USER,
                                 context=CONTEXT) as transaction:
            model, = self.model.search([('model', '=', 'test.access')])

            test, = self.test_access.create([{}])
コード例 #4
0
ファイル: test_access.py プロジェクト: kret0s/gnuhealth-live
# -*- coding: utf-8 -*-
# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
        install_module
from trytond.transaction import Transaction
from trytond.exceptions import UserError

CONTEXT = CONTEXT.copy()
CONTEXT['_check_access'] = True


class ModelAccessTestCase(unittest.TestCase):
    'Test Model Access'

    def setUp(self):
        install_module('tests')
        self.model_access = POOL.get('ir.model.access')
        self.test_access = POOL.get('test.access')
        self.model = POOL.get('ir.model')
        self.group = POOL.get('res.group')

    def test0010perm_read(self):
        'Test Read Access'
        with Transaction().start(DB_NAME, USER,
                context=CONTEXT) as transaction:
            model, = self.model.search([('model', '=', 'test.access')])

            test, = self.test_access.create([{}])