本文整理汇总了Python中trytond.config.config.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(LDAPAuthenticationTestCase, self).setUp()
methods = config.get('session', 'authentications')
config.set('session', 'authentications', 'ldap')
self.addCleanup(config.set, 'session', 'authentications', methods)
config.add_section(section)
config.set(section, 'uri', 'ldap://localhost/dc=tryton,dc=org')
self.addCleanup(config.remove_section, section)
开发者ID:coopengo,项目名称:ldap_authentication,代码行数:8,代码来源:test_ldap_authentication.py
示例2: run
def run(self):
from trytond.config import config
config.set(
'database', 'uri', 'postgresql://postgres:[email protected]:5432/'
)
os.environ['DB_NAME'] = 'test_' + str(int(time.time()))
from tests import suite
test_result = unittest.TextTestRunner(verbosity=3).run(suite())
if test_result.wasSuccessful():
sys.exit(0)
sys.exit(-1)
开发者ID:openlabs,项目名称:trytond-shipping,代码行数:14,代码来源:setup.py
示例3: run
def run(self):
from trytond.config import config
config.set("database", "uri", "postgresql://postgres:[email protected]:5432/")
os.environ["DB_NAME"] = "test_" + str(int(time.time()))
from tests import suite
test_result = unittest.TextTestRunner(verbosity=3).run(suite())
if test_result.wasSuccessful():
sys.exit(0)
sys.exit(-1)
开发者ID:usudaysingh,项目名称:trytond-customs-value,代码行数:14,代码来源:setup.py
示例4: run
def run(self):
if self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require)
from trytond.config import config
os.environ['TRYTOND_DATABASE_URI'] = 'sqlite://'
config.set('email', 'from', '[email protected]')
os.environ['DB_NAME'] = ':memory:'
from tests import suite
test_result = unittest.TextTestRunner(verbosity=3).run(suite())
if test_result.wasSuccessful():
sys.exit(0)
sys.exit(-1)
开发者ID:openlabs,项目名称:trytond-sale-confirmation-email,代码行数:15,代码来源:setup.py
示例5: install_module
def install_module(request):
"""Install tryton module in specified database.
"""
reuse_db = request.config.getoption("--reuse-db")
if request.config.getoption("--db") == 'sqlite':
os.environ['TRYTOND_DATABASE_URI'] = "sqlite://"
if reuse_db:
# A hack to check if the database exists and if it
# does, load that and run tests.
Database = backend.get('Database')
# cursor.test forgets to set flavor!
# no time to report a bug!
Flavor.set(Database.flavor)
os.environ['DB_NAME'] = 'fulfilio'
else:
os.environ['DB_NAME'] = ':memory:'
elif request.config.getoption("--db") == 'postgres':
os.environ['TRYTOND_DATABASE_URI'] = "postgresql://"
if reuse_db:
os.environ['DB_NAME'] = 'test_fulfilio'
else:
os.environ['DB_NAME'] = 'test_' + str(int(time.time()))
if reuse_db:
Database = backend.get('Database')
database = Database().connect()
cursor = database.cursor()
databases = database.list(cursor)
cursor.close()
if os.environ['DB_NAME'] in databases:
if request.config.getoption("--reset-db"):
cursor = database.cursor()
databases = database.drop(cursor, os.environ['DB_NAME'])
cursor.close()
else:
# tryton test forgets to init the pool
# for existing database
Pool(os.environ['DB_NAME']).init()
config.set('database', 'uri', os.environ['TRYTOND_DATABASE_URI'])
from trytond.tests import test_tryton
test_tryton.install_module('payment_gateway_stripe')
开发者ID:fulfilio,项目名称:trytond-payment-gateway-stripe,代码行数:45,代码来源:conftest.py
示例6: run
def run(self):
if self.distribution.tests_require:
self.distribution.fetch_build_eggs(self.distribution.tests_require)
os.environ['TRYTOND_DATABASE_URI'] = 'postgresql://'
os.environ['DB_NAME'] = 'test_' + str(int(time.time()))
from trytond.config import config
# Add elastic search test configuration
config.add_section('elastic_search')
config.set('elastic_search', 'server_uri', 'localhost:9200')
from tests import suite
test_result = unittest.TextTestRunner(verbosity=3).run(suite())
if test_result.wasSuccessful():
sys.exit(0)
sys.exit(-1)
开发者ID:openlabs,项目名称:trytond-product-elasticsearch,代码行数:18,代码来源:setup.py
示例7: test_user_get_login
def test_user_get_login(self):
'Test User.get_login'
pool = Pool()
User = pool.get('res.user')
@patch.object(ldap3, 'Connection')
@patch.object(User, 'ldap_search_user')
def get_login(login, password, find, ldap_search_user, Connection):
con = Connection.return_value
con.bind.return_value = bool(find)
if find:
ldap_search_user.return_value = [('dn', {'uid': [find]})]
else:
ldap_search_user.return_value = None
user_id = User.get_login(login, {
'password': password,
})
if find:
Connection.assert_called_with(ANY, ANY, password)
return user_id
# Test existing user
user, = User.search([('login', '=', 'admin')])
self.assertEqual(get_login('admin', 'admin', 'admin'), user.id)
self.assertEqual(get_login('AdMiN', 'admin', 'admin'), user.id)
# Test new user
self.assertFalse(get_login('foo', 'bar', None))
self.assertFalse(get_login('foo', 'bar', 'foo'))
# Test create new user
config.set(section, 'create_user', 'True')
user_id = get_login('foo', 'bar', 'foo')
foo, = User.search([('login', '=', 'foo')])
self.assertEqual(user_id, foo.id)
self.assertEqual(foo.name, 'foo')
# Test create new user with different case
user_id = get_login('BaR', 'foo', 'bar')
bar, = User.search([('login', '=', 'bar')])
self.assertEqual(user_id, bar.id)
self.assertEqual(bar.name, 'bar')
开发者ID:coopengo,项目名称:ldap_authentication,代码行数:42,代码来源:test_ldap_authentication.py
示例8: test_user_get_login
def test_user_get_login(self):
'Test User.get_login'
pool = Pool()
User = pool.get('res.user')
@patch.object(ldap, 'initialize')
@patch.object(User, 'ldap_search_user')
def get_login(login, password, find, ldap_search_user, initialize):
con = initialize.return_value
con.simple_bind_s.return_value = True
if find:
ldap_search_user.return_value = [('dn', {'uid': [find]})]
else:
ldap_search_user.return_value = None
return User.get_login(login, password)
# Test existing user
user, = User.search([('login', '=', 'admin')])
self.assertEqual(get_login('admin', 'admin', None), user.id)
self.assertEqual(get_login('admin', 'admin', 'admin'), user.id)
self.assertEqual(get_login('AdMiN', 'admin', 'admin'), user.id)
# Test new user
self.assertFalse(get_login('foo', 'bar', None))
self.assertFalse(get_login('foo', 'bar', 'foo'))
# Test create new user
config.set(section, 'create_user', 'True')
user_id = get_login('foo', 'bar', 'foo')
foo, = User.search([('login', '=', 'foo')])
self.assertEqual(user_id, foo.id)
self.assertEqual(foo.name, 'foo')
# Test create new user with different case
user_id = get_login('BaR', 'foo', 'bar')
bar, = User.search([('login', '=', 'bar')])
self.assertEqual(user_id, bar.id)
self.assertEqual(bar.name, 'bar')
开发者ID:kret0s,项目名称:tryton3_8,代码行数:38,代码来源:test_ldap_authentication.py
示例9: install_module
def install_module(request):
"""Install tryton module in specified database.
"""
if request.config.getoption("--db") == 'sqlite':
os.environ['TRYTOND_DATABASE_URI'] = "sqlite://"
os.environ['DB_NAME'] = ':memory:'
elif request.config.getoption("--db") == 'postgres':
os.environ['TRYTOND_DATABASE_URI'] = "postgresql://"
os.environ['DB_NAME'] = 'test_' + str(int(time.time()))
config.set('database', 'uri', os.environ['TRYTOND_DATABASE_URI'])
os.environ['TRYTOND_ENCRYPTED_FIELD__SECRET_KEY'] = Fernet.generate_key()
from trytond.tests import test_tryton
from trytond.pool import Pool
Pool.register(
EncryptedCharField,
EncryptedTextField,
EncryptedSelectionField,
module='tests', type_='model'
)
test_tryton.install_module('tests')
开发者ID:fulfilio,项目名称:trytond-encrypted-field,代码行数:23,代码来源:conftest.py
示例10: Consulting
Test GLS Integration
:copyright: (c) 2014 by Openlabs Technologies & Consulting (P) Limited
:license: GPLv3, see LICENSE for more details.
"""
from decimal import Decimal
from datetime import datetime
from dateutil.relativedelta import relativedelta
import os
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
from trytond.config import config
config.set('database', 'path', '.')
class TestGLSShipping(unittest.TestCase):
"""
Test GLS Integration
"""
def setUp(self):
trytond.tests.test_tryton.install_module('shipping_gls')
self.Address = POOL.get('party.address')
self.Sale = POOL.get('sale.sale')
self.SaleLine = POOL.get('sale.line')
self.SaleConfig = POOL.get('sale.configuration')
self.PackageType = POOL.get('stock.package.type')
self.Package = POOL.get('stock.package')
开发者ID:openlabs,项目名称:trytond-shipping-gls,代码行数:31,代码来源:test_shipment.py
示例11: Consulting
TestTask
:copyright: (c) 2013-2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import unittest
import json
import smtplib
from minimock import Mock
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
from test_base import TestBase
from trytond.config import config
config.set('database', 'path', '/tmp')
config.set('email', 'from', '[email protected]')
smtplib.SMTP = Mock('smtplib.SMTP')
smtplib.SMTP.mock_returns = Mock('smtp_connection')
class TestTask(TestBase):
'''
Test Task
'''
def get_template_source(self, name):
"""
Return templates.
"""
开发者ID:openlabs,项目名称:nereid-project,代码行数:30,代码来源:test_task.py
示例12: TestPagination
"""
import time
import datetime
from dateutil.relativedelta import relativedelta
from decimal import Decimal
from pyes.managers import Indices
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT
from trytond.transaction import Transaction
from trytond.config import config
from nereid.testing import NereidTestCase
from pagination import ElasticPagination
config.add_section('elastic_search')
config.set('elastic_search', 'server_uri', 'http://localhost:9200')
class TestPagination(NereidTestCase):
"""
Test Pagination
"""
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_webshop_elastic_search'
)
开发者ID:mbehrle,项目名称:nereid-webshop-elastic-search,代码行数:30,代码来源:test_pagination.py
示例13: Consulting
TestParty
:copyright: (c) 2014-2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import time
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import DB_NAME, USER, CONTEXT, POOL
from trytond.transaction import Transaction
from trytond.config import config
# Add elastic search test configuration
config.add_section('elastic_search')
config.set('elastic_search', 'server_uri', "localhost:9200")
class TestParty(unittest.TestCase):
"""
Test Party
"""
def setUp(self):
trytond.tests.test_tryton.install_module('party_elasticsearch')
self.Party = POOL.get('party.party')
self.IndexBacklog = POOL.get('elasticsearch.index_backlog')
self.ElasticDocumentType = POOL.get('elasticsearch.document.type')
self.ElasticConfig = POOL.get('elasticsearch.configuration')
def update_mapping(self):
开发者ID:openlabs,项目名称:trytond-party-elasticsearch,代码行数:31,代码来源:test_party.py
示例14: TestNereidS3
sys.path.insert(0, os.path.dirname(DIR))
import unittest
from mock import patch
from boto.s3 import connection
from boto.s3.bucket import Bucket
from boto.s3.key import Key
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view,\
test_depends
from trytond.transaction import Transaction
from trytond.exceptions import UserError
from trytond.config import config
config.set('nereid_s3', 's3_access_key', 'ABCD')
config.set('nereid_s3', 's3_secret_key', '123XYZ')
config.set('nereid_s3', 's3_bucket_name', 'tryton-test-s3')
class TestNereidS3(unittest.TestCase):
'''
Test Nereid S3
'''
def setUp(self):
trytond.tests.test_tryton.install_module('nereid_s3')
self.static_file = POOL.get('nereid.static.file')
self.static_folder = POOL.get('nereid.static.folder')
# Mock S3Connection
开发者ID:openlabs,项目名称:trytond-nereid-s3,代码行数:31,代码来源:test_nereid_s3.py
示例15: setUp
def setUp(self):
super(LDAPAuthenticationTestCase, self).setUp()
config.add_section(section)
config.set(section, 'uri', 'ldap://localhost/dc=tryton,dc=org')
开发者ID:kret0s,项目名称:tryton3_8,代码行数:4,代码来源:test_ldap_authentication.py
示例16: BaseTestCheckout
"""
import os
import json
import unittest
from mock import patch
from decimal import Decimal
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT
from trytond.config import config
from trytond.transaction import Transaction
from trytond import backend
from trytond.modules.nereid_cart_b2c.tests.test_product import BaseTestCase
config.set("email", "from", "[email protected]")
class BaseTestCheckout(BaseTestCase):
"""Test Checkout Base"""
@classmethod
def setUpClass(cls):
print "====== Tests are running on %s ========" % backend.name()
def setUp(self):
super(BaseTestCheckout, self).setUp()
trytond.tests.test_tryton.install_module("nereid_shipping")
trytond.tests.test_tryton.install_module("shipping_ups")
self.Carrier = POOL.get("carrier")
开发者ID:mbehrle,项目名称:nereid-shipping,代码行数:31,代码来源:test_checkout.py
示例17: NereidCRMTestCase
import datetime
import simplejson as json
from dateutil.relativedelta import relativedelta
DIR = os.path.abspath(
os.path.normpath(
os.path.join(
__file__, '..', '..', '..', '..', '..', 'trytond'
)
)
)
if os.path.isdir(DIR):
sys.path.insert(0, os.path.dirname(DIR))
from mock import patch
from trytond.config import config
config.set('email', 'from', '[email protected]')
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
from trytond.tests.test_tryton import test_view, test_depends
from nereid.testing import NereidTestCase
class NereidCRMTestCase(NereidTestCase):
'''
Test Nereid CRM module.
'''
def setUp(self):
trytond.tests.test_tryton.install_module('nereid_crm')
开发者ID:openlabs,项目名称:nereid-crm,代码行数:31,代码来源:test_opportunity.py
示例18: TestSale
# -*- coding: utf-8 -*-
"""
tests/test_sale.py
"""
import unittest
import datetime
from dateutil.relativedelta import relativedelta
from decimal import Decimal
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, USER, DB_NAME, CONTEXT
from trytond.transaction import Transaction
from trytond.pyson import Eval
from trytond.config import config
config.set('email', 'from', '[email protected]')
class TestSale(unittest.TestCase):
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('sale_confirmation_email')
self.Currency = POOL.get('currency.currency')
self.Company = POOL.get('company.company')
self.Party = POOL.get('party.party')
self.User = POOL.get('res.user')
开发者ID:priyankarani,项目名称:trytond-sale-confirmation-email,代码行数:31,代码来源:test_sale.py
示例19: BaseTestCase
import random
import datetime
from decimal import Decimal
from dateutil.relativedelta import relativedelta
import pycountry
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, USER, CONTEXT
from nereid.testing import NereidTestCase
from trytond.transaction import Transaction
from trytond.config import config
config.set("database", "path", "/tmp")
class BaseTestCase(NereidTestCase):
"""
Base test Case for nereid webshop
"""
def setUp(self):
trytond.tests.test_tryton.install_module("nereid_webshop")
self.FiscalYear = POOL.get("account.fiscalyear")
self.Account = POOL.get("account.account")
self.PaymentTerm = POOL.get("account.invoice.payment_term")
self.Currency = POOL.get("currency.currency")
self.Company = POOL.get("company.company")
self.Party = POOL.get("party.party")
self.Sale = POOL.get("sale.sale")
self.Cart = POOL.get("nereid.cart")
开发者ID:priyankarani,项目名称:nereid-webshop,代码行数:31,代码来源:test_base.py
示例20: TestUPS
from decimal import Decimal
from time import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from lxml import objectify
import unittest
import trytond.tests.test_tryton
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT
from trytond.transaction import Transaction
from trytond.config import config
from trytond.error import UserError
config.set("database", "path", ".")
class TestUPS(unittest.TestCase):
"""Test UPS Integration
"""
def setUp(self):
trytond.tests.test_tryton.install_module("shipping_ups")
self.Address = POOL.get("party.address")
self.Sale = POOL.get("sale.sale")
self.SaleConfig = POOL.get("sale.configuration")
self.UPSService = POOL.get("ups.service")
self.Product = POOL.get("product.product")
self.Uom = POOL.get("product.uom")
self.Account = POOL.get("account.account")
开发者ID:riteshshrv,项目名称:trytond-shipping-ups,代码行数:30,代码来源:test_ups.py
注:本文中的trytond.config.config.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论