How to use the trytond.tests.test_tryton.POOL.get function in trytond

To help you get started, we’ve selected a few trytond examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openlabs / nereid-project / tests / test_company.py View on Github external
def setUp(self):
        """
        Set up data used in the tests.
        this method is called before each test function execution.
        """
        trytond.tests.test_tryton.install_module('nereid_project')
        self.Website = POOL.get('nereid.website')
        self.NereidUser = POOL.get('nereid.user')
        self.Currency = POOL.get('currency.currency')
        self.Company = POOL.get('company.company')
        self.Party = POOL.get('party.party')
        self.Employee = POOL.get('company.employee')
        self.Language = POOL.get('ir.lang')
        self.Website = POOL.get('nereid.website')
        self.Locale = POOL.get('nereid.website.locale')
        self.Permission = POOL.get('nereid.permission')
github openlabs / nereid-project / tests / test_project.py View on Github external
def setUp(self):
        """
        Set up data used in the tests.
        this method is called before each test function execution.
        """
        trytond.tests.test_tryton.install_module('nereid_project')
        self.ActivityAllowedModel = POOL.get('nereid.activity.allowed_model')
        self.Model = POOL.get('ir.model')
        self.Project = POOL.get('project.work')
        self.Company = POOL.get('company.company')
        self.Employee = POOL.get('company.employee')
        self.Currency = POOL.get('currency.currency')
        self.Language = POOL.get('ir.lang')
        self.Website = POOL.get('nereid.website')
        self.NereidUser = POOL.get('nereid.user')
        self.URLMap = POOL.get('nereid.url_map')
        self.Party = POOL.get('party.party')
        self.User = POOL.get('res.user')
        self.Action = POOL.get('ir.action')
        self.TimesheetLine = POOL.get('timesheet.line')
        self.Tag = POOL.get('project.work.tag')
        self.History = POOL.get('project.work.history')
        self.ProjectInvitation = POOL.get('project.work.invitation')
        self.Attachment = POOL.get('ir.attachment')
github openlabs / tryton-restful / tests / test_rest_api.py View on Github external
def test_collection_get_pagination(self):
        """
        GET with a domain
        """
        # Fetch result from tryton api first to compare with rest api
        with Transaction().start(DB_NAME, 0, readonly=True):
            IrModel = POOL.get('ir.model')
            count = IrModel.search_count([])

        with app.test_client() as c:
            total_count = 0
            for page in xrange(1, 100):
                # Try to Iterate over a 100 pages
                result = c.get(
                    '/%s/model/ir.model?page=%d' % (DB_NAME, page),
                    headers={'Authorization': get_auth_header()}
                )
                page_count = len(json.loads(result.data)['items'])
                total_count += page_count
                if not page_count:
                    break

            # ensure that the total count matches
github openlabs / trytond-report-html / tests / test_report.py View on Github external
def test_0020_render_unicode(self):
        '''
        Render the report without PDF conversion but having unicode template
        '''
        UserReport = POOL.get('res.user', type='report')
        IRReport = POOL.get('ir.action.report')

        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            IRReport.create({
                'name': 'HTML Report',
                'model': 'res.user',
                'report_name': 'res.user',
                'report_content': buffer("<h1>Héllø, ${data['name']}!</h1>"),
                'extension': 'html',
            })

            val = UserReport.execute([USER], {'name': u'Cédric'})
            self.assertEqual(val[0], u'html')
            self.assertEqual(
                str(val[1]), '<h1>Héllø, Cédric!</h1>'
            )
github openlabs / trytond-amazon-mws / tests / test_product.py View on Github external
def test_0020_create_product_using_amazon_data(self):
        """
        Tests if product is created using amazon data
        """
        Product = POOL.get('product.product')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()

            with Transaction().set_context(
                {'current_channel': self.sale_channel.id}
            ):
                self.assertEqual(Product.search([], count=True), 0)

                product_data = load_json('products', 'product-1')
                Product.create_using_amazon_data(product_data)

                self.assertEqual(Product.search([], count=True), 1)
github openlabs / nereid-project / tests / test_task.py View on Github external
def test_0200_create_task_with_multiple_tags(self):
        """
        Tests that task can be created with mulitple tags only if user is

        1. Project Admin or
        2. Admin member of the project
        """
        ProjectMember = POOL.get('project.work.member')

        # As non admin member
        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.create_defaults_for_project()
            app = self.get_app(DEBUG=True)

            with app.test_client() as c:
                # User Login
                response = self.login(c, self.reg_user1.email, 'password')

                self.assertEqual(
                    len(self.Project.search([('type', '=', 'task')])),
                    3
                )

                # Create Task
github openlabs / trytond-amazon-mws / tests / test_base.py View on Github external
self.Subdivision = POOL.get('country.subdivision')
        self.AccountTemplate = POOL.get('account.account.template')
        self.Account = POOL.get('account.account')
        self.CreateChartAccount = POOL.get(
            'account.create_chart', type="wizard"
        )
        self.Location = POOL.get('stock.location')
        self.User = POOL.get('res.user')
        self.PaymentTerm = POOL.get('account.invoice.payment_term')
        self.FiscalYear = POOL.get('account.fiscalyear')
        self.PriceList = POOL.get('product.price_list')
        self.Sequence = POOL.get('ir.sequence')
        self.SequenceStrict = POOL.get('ir.sequence.strict')
        self.AccountConfiguration = POOL.get('account.configuration')
        self.Property = POOL.get('ir.property')
        self.ModelField = POOL.get('ir.model.field')
        self.SaleChannel = POOL.get('sale.channel')

        with Transaction().set_context(company=None):
            self.party, = self.Party.create([{
                'name': 'ABC',
            }])
            self.usd, = self.Currency.create([{
                'name': 'US Dollar',
                'code': 'USD',
                'symbol': '$',
            }])
            self.company, = self.Company.create([{
                'party': self.party.id,
                'currency': self.usd.id,
            }])
github openlabs / trytond-report-html / tests / test_report.py View on Github external
def test_0030_render_pdf(self):
        '''
        Render the report in PDF
        '''
        UserReport = POOL.get('res.user', type='report')
        IRReport = POOL.get('ir.action.report')

        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            IRReport.create({
                'name': 'HTML Report',
                'model': 'res.user',
                'report_name': 'res.user',
                'report_content': buffer("<h1>Héllø, ${data['name']}!</h1>"),
                'extension': 'pdf',
            })

            val = UserReport.execute([USER], {'name': u'Cédric'})
            self.assertEqual(val[0], u'pdf')

            with tempfile.TemporaryFile() as file:
                file.write(str(val[1]))
                pdf = PdfFileReader(file)
github openlabs / trytond-amazon-mws / tests / test_base.py View on Github external
def get_account_by_kind(self, kind, company=None, silent=True):
        """Returns an account with given spec

        :param kind: receivable/payable/expense/revenue
        :param silent: dont raise error if account is not found
        """
        Account = POOL.get('account.account')
        Company = POOL.get('company.company')

        if company is None:
            company, = Company.search([], limit=1)

        accounts = Account.search([
            ('kind', '=', kind),
            ('company', '=', company.id)
        ], limit=1)
        if not accounts and not silent:
            raise Exception("Account not found")
        return accounts and accounts[0].id or None
github openlabs / trytond-amazon-mws / tests / test_sale.py View on Github external
def test_0010_create_sale_using_amazon_data(self):
        """
        Tests creation of sale order using amazon data
        """
        Sale = POOL.get('sale.sale')
        Product = POOL.get('product.product')
        Party = POOL.get('party.party')
        ContactMechanism = POOL.get('party.contact_mechanism')

        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()

            with Transaction().set_context({
                'current_channel': self.sale_channel.id,
            }):

                orders = Sale.search([])
                self.assertEqual(len(orders), 0)

                order_data = load_json(
                    'orders', 'order_list'
                )['Orders']['Order']
                line_data = load_json(