diff --git a/__init__.py b/__init__.py index 1b05f05..f620b14 100644 --- a/__init__.py +++ b/__init__.py @@ -5,6 +5,7 @@ from trytond.pool import Pool from . import user from . import config from . import calls +from . import test_configuration __all__ = ['register'] @@ -15,8 +16,10 @@ def register(): calls.Caller, user.User, config.Configuration, + test_configuration.TestConfigurationStart, module='tryphone', type_='model') Pool.register( + test_configuration.TestConfiguration, module='tryphone', type_='wizard') Pool.register( module='tryphone', type_='report') diff --git a/test_configuration.py b/test_configuration.py new file mode 100644 index 0000000..59d28b9 --- /dev/null +++ b/test_configuration.py @@ -0,0 +1,37 @@ +from trytond.model import ModelView, fields +from trytond.wizard import Wizard, StateView, StateTransition, Button +from trytond.pool import Pool +from trytond.transaction import Transaction + +class TestConfigurationStart(ModelView): + "Test configuration start form" + + __name__ = 'tryphone.test_configuration.start' + + to = fields.Char('To') + + +class TestConfiguration(Wizard): + __name__ = 'tryphone.test_configuration' + + start = StateView('tryphone.test_configuration.start', + '', + [ + Button( + "Cancel", 'end', 'tryton-cancel'), + Button( + "Import", 'try_call', 'tryton-ok', default=True) + ]) + try_call = StateTransition() + + def transition_try_call(self): + pool = Pool() + Caller = pool.get('tryphone.caller') + User = pool.get('res.user') + user = User(Transaction().user) + destination = self.start.to + Caller.call( + user=user, + destination=self.start.to + ) + return 'end' diff --git a/tests/scenario_config_pbx.rst b/tests/scenario_config_pbx.rst index bd50bf3..bd3e398 100644 --- a/tests/scenario_config_pbx.rst +++ b/tests/scenario_config_pbx.rst @@ -17,7 +17,7 @@ Usuario con extensión:: >>> config_pbx = ConfigPBX() >>> config_pbx.host = '127.0.0.1' >>> config_pbx.port = 8706 - >>> config_pbx.api_client = 'freetwitch' + >>> config_pbx.api_client = 'test' >>> config_pbx.api_password = 'some_password' >>> config_pbx.save() >>> config_pbx.host @@ -25,7 +25,24 @@ Usuario con extensión:: >>> config_pbx.port 8706 >>> config_pbx.api_client - 'freetwitch' + 'test' >>> config_pbx.api_password 'some_password' +Hacer llamada de prueba:: + + >>> User = Model.get('res.user') + >>> users = User.find() + >>> users[0].login + 'admin' + >>> admin = users[0] + >>> admin.phone_extension = '120' + >>> admin.save() + + >>> test_configuration = Wizard('tryphone.test_configuration', []) + >>> test_configuration.form.to = '8099' + >>> test_configuration.execute('try_call') + >>> CallLog = Model.get('tryphone.call_log') + >>> call_logs = CallLog.find() + >>> call_logs[0].destination + '8099'